Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scroll to a specific Element Using html

Tags:

html

css

Is there a method in html which makes the webpage scroll to a specific Element using HTML !?

like image 340
M1rwen Avatar asked Jul 14 '14 14:07

M1rwen


People also ask

How do I scroll to a specific div in HTML?

If you want to scroll the current document to a particular place, the value of HREF should be the name of the anchor to which to scroll, preceded by the # sign. If you want to open another document at an anchor, give the URL for the document, followed by #, followed by the name of the anchor.

How do you scroll an element in HTML?

Definition and UsageThe scrollIntoView() method scrolls an element into the visible area of the browser window.

How do you auto scroll to a section in HTML?

You can use . scrollIntoView() for this. It will bring a specific element into the viewport.


1 Answers

Yes you use this

<a href="#google"></a>  <div id="google"></div> 

But this does not create a smooth scroll just so you know.

You can also add in your CSS

html {   scroll-behavior: smooth; } 
like image 190
EasyBB Avatar answered Sep 22 '22 11:09

EasyBB