What is the href HTML attribute?
In HTML, the Href attribute is used to create links both within the same webpage and between different pages. In simple terms, whenever you see a clickable link on a page, it is typically a Href HTML element, commonly known as a link.
Types of href links
Standard links
A standard link in the page source code looks like this:
< a Href=”https://www.domain.com/page”>This is an external link</a>
Anchor links
Anchor (or jump) links allow navigation to a specific section within a page:
< a href=”https://www.domain.com/page#section”>This link jumps to a specific section</a>
Mailto links
Email addresses can also be linked within a page. When clicked, the default email client opens, with the recipient field already filled in:
< a href=”mailto:name@email.com”>email address</a>
Target parameters for href links
- _blank: Opens the linked page in a new browser window or tab.
- _self: Loads the linked page in the same window or tab.
- _top: Loads the linked page in the full browser window (useful with frames).
- _parent: Loads the linked page in the parent frame (used with frame structures).