Links are what make the web a web. A link is made with the <a> tag (short for anchor):
<a href="https://www.wikipedia.org">Visit Wikipedia</a>
This is the first tag you have seen with an attribute. Attributes go inside the opening tag and give the browser extra information. They are written as name="value".
hrefis the address the link goes to.- The text between the tags is what people click on.
Good link text
Write link text that says where the link goes. "Read our opening hours" is clear. "Click here" is not, especially for people who use a screen reader to hear a list of the links on a page.
Opening in a new tab
Add target="_blank" to open the link in a new tab:
<a href="https://www.wikipedia.org" target="_blank">Visit Wikipedia</a>
In this preview, links do not open, so you can click them safely. A message in the console shows where the link points.
Your Task
- Turn the words Mozilla Developer Network into a link to
https://developer.mozilla.org. - Add a second paragraph with a link to any other website you like. Remember to start the address with
https://.
- "Mozilla Developer Network" is a link to
https://developer.mozilla.org - There is a second link to a different address that starts with
https:// - The links are closed, so the rest of the text is not part of a link
Lesson complete!
Next Lesson: Images