<html>
<body>
<main>
<h1>CatPhotoApp</h1>
<h2>Cat Photos</h2>
<!-- TODO: Add link to cat photos -->
<p>See more <a target="_blank" href="https://freecatphotoapp.com">cat photos</a> in our gallery.</p>
<a href="https://freecatphotoapp.com" target="_blank"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."</a>
</main>
</body>
</html>
Welcome to our community!
Your img element doesn’t have the closing angle bracket >
:
<a href="smth"><img src="smth"**>**</a>
It is positioned right before the closing ‘a’ tag </a>
.
Thank you!
Just a an odd question, is the closing tag necessary as the link still works or is it best practice?
the reason the link works is because a software developer who works for the company that makes the browser decided to try to -guess- what you meant and assume that the img element is the one you wanted to turn into the link. The software developer(s) then wrote code to handle this missing anchor closing tag.
In other words: The browser is used to people writing syntactically incorrect code and tried to compensate for that.
But writing bad code just because the browser doesn’t stop you doesn’t mean you should.