HTML Links
The <a> (anchor) tag creates a hyperlink, using the href attribute to specify the destination URL. Links can point to other pages, sections within a page, email addresses, or files.
The target attribute controls where the link opens β target="_blank" opens it in a new tab. Anchor links use an id and a hash (#) to jump to specific parts of a page.
<a href="url">link text</a>Basic and external links
<a href="page.html">Link</a> creates a clickable link. Use target="_blank" to open external links in a new tab, often combined with rel="noopener" for security.
Email and anchor links
mailto: links open the user's email client. Linking to href="#section-id" scrolls to an element with a matching id on the same page.
<a href="https://example.com" target="_blank" rel="noopener">Visit Example</a>Visit Example (opens in new tab)target="_blank" opens the link in a new browser tab.
<a href="mailto:info@example.com">Email us</a>
<a href="#section2">Jump to Section 2</a>Email us / Jump to Section 2mailto links open email apps; # links scroll to page anchors.
Key points
- <a href="..."> creates a hyperlink.
- target="_blank" opens links in a new tab.
- mailto: links open the default email client.
- href="#id" jumps to an element with a matching id.
