Back to subject
HTML5/HTML Links

Build Two Links

Practical lesson

Let's read a link from the browser's point of view and then change what it does.

- <a> is the HTML element used to create a hyperlink. - The href attribute tells the browser where the link should go. - The words between <a> and </a> are the clickable link text. - Use clear link text so a visitor can understand the destination without guessing. - A relative URL such as about.html can point to another page in the same site. - An absolute URL such as https://example.com points to a full web address. - target="_blank" can open a destination in a new browsing context; when you use it for an external link, rel="noopener" is a useful security setting. - mailto: can open an email program, while tel: can create a phone link on supported devices. - download can ask the browser to download a linked resource when the browser and resource allow it.

The key idea is that the text makes the link understandable, while href controls its destination.

Try it yourself
Code

Starter example

Code
<p><a href="https://example.com">Visit Example</a></p>
<p><a href="about.html">About Us</a></p>
Live preview