All hail the mighty <a> element
The a
tag (short for anchor tag) is arguably the most important and defining tag of HTML. The anchor tag is the tag used to link from the document a user is on to another document elsewhere on the internet, or another point in the same document.
You can read the specification for the <a>
element here: https://html.spec.whatwg.org/#the-a-element.
A welcome benefit of HTML5 is that we can wrap multiple elements in an a
tag. In prior versions of HTML, if you wanted your markup to validate, it was necessary to wrap each element in its own a
tag. For example, look at the following code:
<h2><a href="index.html">The home page</a></h2>
<p><a href="index.html">This paragraph also links to the home page</a></p>
<a href="index.html">
<img src="home-image.png" alt="A rendering of the home page" />
</a>
...