Links in HTML
Links in HTML
Links are a fundamental part of the web, allowing users to navigate from one page
to another. In HTML, links are created using the <a> (anchor) tag, which requires
specific attributes to define how the link behaves. In this section, we'll cover
the essential attributes of links, including href, target, and rel, and explain how
they contribute to web navigation.
1. The href Attribute
The href (hyperlink reference) attribute is the most important attribute for a
link. It defines the destination URL of the link, which can be an external website,
an internal page, or a specific section on the same page.
Example:
In this example, when users click on the text "Visit Example", they will be
directed to https://www.example.com.
The target attribute determines where the linked document will open. There are
several values you can use with the target attribute, including:
Example:
In this example, clicking the link will open the destination website in a new tab.