DEV Community

Discussion on: Understanding HTML Anchor Tag <a>

Collapse
 
grahamthedev profile image
GrahamTheDev • Edited

Hey! Please could you fix the following errors as they are awful habits for a beginner to pick up:

Image Links

Image as a link must have an alt attribute on the image otherwise there is no link text. The alt text should be the same as if the image didn't exist and the link was just text.

Without an alt attribute it is bad for SEO and, more importantly, people using assistive technology have no way of knowing what that link does do you are (unintentionally) excluding them!

JavaScript

<a href="javascript:codeblock">text</a> is an anti-pattern that has not been needed for nearly 15 years since HTML5 and the ability to style buttons.

From the JavaScript section on the MDN article you linked to:

Use a <button> instead. In general, you should only use a hyperlink for navigation to a real URL.

Hell I even wrote a silly article on this very point it is that big of a problem!

Please could you fix the first one and (delete?) or fix the second one so this post doesn't accidentally cause more bad practices!

Other points are great and this will make a useful reference piece for people learning if you fix those two issues. ❤ (unicorn to follow when you fix those points 😉)

Collapse
 
ayabouchiha profile image
Aya Bouchiha

Thank you a lot, your comment is ineffably useful and helpful,
the two issues are fixed 🔧 .

Collapse
 
grahamthedev profile image
GrahamTheDev

Fantastic, I wish all authors responded so quickly and positively, top creator 💪.

🦄 and 📘 added!

Thread Thread
 
ayabouchiha profile image
Aya Bouchiha

I appreciate it a lot 😊