Published by Patrick Mutisya · 14 days ago
A bookmark is a reference that allows a user to jump directly to a specific location within a web page or to a saved web address for later retrieval. In the context of web authoring, two main types are considered:
Page bookmarks are created using HTML elements that define a target and links that refer to that target.
id AttributePlace an id on any element where you want the bookmark to land.
<h2 id="chapter3">Chapter 3: Data Types</h2>
Link to the bookmark with a hash (#) followed by the id value:
<a href="#chapter3">Go to Chapter 3</a>
name Attribute (Deprecated)Older HTML used the name attribute on an empty <a> element.
<a name="section2"></a>
Linking works the same way:
<a href="#section2">Jump to Section 2</a>
Although still supported by browsers, this method is discouraged in favour of id.
idHTML5 encourages the use of semantic tags such as <section>, <article>, or <nav> with an id.
<section id="faq">
<h2>Frequently Asked Questions</h2>
…
</section>
Link:
<a href="#faq">Read the FAQ</a>
Combine the target page’s URL with the hash.
<a href="guide.html#installation">Installation Instructions</a>
| Method | Target Element | HTML Example | Notes |
|---|---|---|---|
| id attribute | Any element (e.g., h2, div) | <h2 id="intro">Introduction</h2> | Recommended for all new pages. |
| name attribute (deprecated) | Empty <a> element | <a name="top"></a> | Supported for backward compatibility only. |
| Semantic element with id | <section>, <article>, etc. | <section id="contact">…</section> | Improves document structure and accessibility. |
| Cross‑page bookmark | Any element with id on the target page | <a href="page.html#section">Link</a> | Useful for multi‑page tutorials. |
id values (e.g., contact-form, not c1).id to linking with #id.