adrian
adrian

Reputation: 133

HTML5 Link to section

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">?

Upvotes: 7

Views: 24065

Answers (1)

thordarson
thordarson

Reputation: 6261

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.

Upvotes: 23

Related Questions