You're off to a great start! So far, you've learned how to add headings, paragraphs, and lists to a web page. We wouldn't be taking advantage of the full power of HTML (and the Internet), however, if we didn't link to other web pages.
You can add links to a web page by adding an anchor element
<a> and including the text of the link in between the opening and closing tags.
<a>This Is A Link To Wikipedia</a>
Wait a minute! Technically, the link in the example above is incomplete. How exactly is the link above supposed to work if there is no URL that will lead users to the actual Wikipedia page?
The anchor element in the example above is incomplete without the
Attributes provide even more information about an element's content. They live directly inside of the opening tag of an element. Attributes are made up of the following two parts:
- The name of the attribute.
- The value of the attribute.
For anchor elements, the name of the attribute is
href and its value must be set to the URL of the page you'd like the user to visit.
<a href="https://www.wikipedia.org/">This Is A Link To Wikipedia</a>
In the example above, the
href attribute has been set to the value of the correct URL
https://www.wikipedia.org/. The example now shows the correct use of an anchor element.
Note: When reading technical documentation, you may come across the term hyperlink. Not to worry, this is simply the technical term for link and, often times, these terms are used interchangeably.