Consider following code snippet:

<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</p>
<h2 id="preface">Ut enim ad minim veniam.</h2> 
<p>
Quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
How can you make a link to an <h2> element with id="preface"?
Explanation
The id attribute specifies a unique id for an HTML element (the value must be unique within the HTML document). The id attribute is most used to point to a style in a style sheet, and by JavaScript (via the HTML DOM (Document Object Model) to manipulate the element with the specific id. In HTML5, the id attribute can be used on any HTML element (it will validate on any HTML element. However, it is not necessarily useful). Specifies a unique id for the element.

Naming rules:
Must contain at least one character.
Must not contain any space characters.
In HTML, all values are case-insensitive.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
HTML & CSS quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes