Be able to create a bookmark within a web page using an id attribute

Resources | Subject Notes | Information Communication Technology ICT

Creating a Bookmark with an ID Attribute

This section explains how to create a bookmark within a webpage using the id attribute. Bookmarks allow users to quickly navigate to specific sections of a long webpage.

Understanding the id Attribute

The id attribute is used to give a unique name to an HTML element. This name can then be used to link to that specific element from other parts of the page or from external links.

Steps to Create a Bookmark

  1. Identify the section of the page where you want to create a bookmark.
  2. Add the id attribute to the starting element of that section.
  3. Create a link to the bookmark from another part of the page or from an external link, using the # symbol followed by the id.

Example HTML Code

Element Purpose
Starting Element The HTML element that marks the beginning of the bookmark section (e.g., a

,

, etc.).

id Attribute Assigns a unique name to the starting element.
Bookmark Link A hyperlink that points to the element with the specified id.

Here's an example of how to create a bookmark:

Suggested diagram: A webpage with a section highlighted and a link to that section using an id attribute.

This is the introduction to the webpage.

Some other content here...

More content...

Go to Introduction

Explanation of the Code

In this example, the

element containing the introduction text has the id attribute set to "introduction". The tag with the href attribute set to "#introduction" creates a link that will scroll the user to the

element with the id "introduction" when clicked.

Using Bookmarks

Bookmarks are useful for making long webpages easier to navigate. Users can quickly jump to the section they are interested in by clicking on the bookmark link.

Important Considerations

Ensure that the id attribute is unique within the entire HTML document. Avoid using spaces or special characters in id names. The id attribute should always be unique within a single HTML document.