Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Link to section

Tags:

html

Well, in HTML 4.01 with for example <div id="example"> I could make <a href="#example"> to scroll to that div.

How can I make the same effect with <section class="asd xyz">?

like image 902
adrian Avatar asked Jan 26 '13 23:01

adrian


People also ask

Can you hyperlink to a specific part of a web page?

It'll show you HTML code, look for an ID tag or Value option. Once you find it, copy it on your clipboard. Next, take the URL of the web page and append the #ID at the end of it. And that's it when someone clicks that link, it will take them directly to that specific part of the webpage.


1 Answers

They work the same. Add an ID to the section and the link should work.

<section id="example"></section>

This code jumps to the section #example.

<a href="#example">Jump to example</a>

EDIT: Pure HTML does not allow you to jump to class names and for a good reason. IDs are unique while classes can be reused as often as you want. Therefore you just can't jump to a class name since it probably doesn't have a single target.

like image 172
thordarson Avatar answered Nov 10 '22 03:11

thordarson