Lecture

a Tag

The <a> tag creates a hyperlink that allows users to navigate to another page.

Here, a stands for Anchor and plays a fundamental role in structuring content based on links within the web ecosystem.


Key Attributes of the a Tag

The <a> tag commonly uses the href, target, and rel attributes.


  • href: Specifies the URL of the page the link goes to
Using the a tag
<a href="https://www.webpal.com">Visit WebPal</a>

  • target: Specifies how to open the linked document. Using target="_blank" makes the page open in a new window or tab.
Open WebPal in a new window
<a href="https://www.webpal.com" target="_blank">Visit in a new window</a>

  • rel: Specifies the relationship between the current page and the linked document. When using target="_blank", it's recommended to use rel="noopener noreferrer" for security purposes, indicating that the new page has no relationship to the current page.
Using the rel attribute
<a href="https://www.webpal.com" target="_blank" rel="noopener noreferrer" >Securely visit in a new window</a >

How to Use the a Tag

The <a> tag can be used as follows:


1. External Website Links

Navigate to an external website upon clicking. Typically, when linking to an external site, target="_blank" is used to open it in a new window.

Go to External Link
<a href="https://example.com" target="_blank">Example Website</a>

2. Navigate to Another Section within the Document

You can move to another section within the same page that is specified by an id (#).

Internal Document Navigation
<a href="#section2">Go to Section 2</a>
Mission
0 / 1

The <a> tag is used to create a link to another page.

True
False

Lecture

AI Tutor

Design

Upload

Notes

Favorites

Help

HTML
CSS
Loading...