Dead Links <a href="#">

I need clarification on dead links.

In the lesson “Make Dead Links Using the Hash Symbol” in the Basic HTML and HTML5 section, we learned by adding <a href="#"></a>, you create a dead link or still are able to add the a attribute before you have identified a link to include.

In the lesson “Turn an Image into a Link,” we learned that you make an image into a link by adding:
<a href="#"><img src="" alt="Three kittens running towards the camera."></a>

How come we are nesting theimg attribute within <a href="#"></a>? How can the a attribute function as as a dead link when in reality, the img attribute does have an assigned link?

The url inside the <img> tag is not a link. It’s telling the browser where to fetch the image from. When the webpage loads, the browser will get the image living at and embed it in the page at that point. If a user clicks on the image, then the browser will navigate to the address it gets from the href attribute of the anchor tag.

The general idea is this:

<a href="http://NAVIGATE/HERE/ON/CLICK"><img src="http://GET/IMAGE/FROM/HERE"></a>

1 Like