HTML Link Attributes: href and target
Learn how to use the href
and target
attributes to control your links' destination and behavior.
Link Attributes: The GPS for your Links
You know how to create a link with `<a>`, but how do you control it? Attributes are like the GPS instructions that tell your links where to go and how to get there.
The 'href' Attribute
The href
attribute specifies the URL of the link's destination. It can be an absolute URL (like `https://www.google.com`) or a relative URL to another page on the same site (like `/about.html`).
The 'target' Attribute
The target
attribute controls where the link opens. Using target="_blank"
is a common practice for external links, as it keeps your site open in the original tab.
Practice Zone
Interactive Test 1: Drag & Drop
Arrastra en el orden correspondiente.
Arrastra las opciones:
Completa el código:
Interactive Test 2: Fill in the Blanks
Rellena los huecos en cada casilla.
<a >Link Text</a>
Practice Example: Code Editor
Create a link that opens in a new tab and directs to `https://www.google.com`. Make sure to use both the `href` and `target` attributes.