Wrap Article Headings In Anchor Tags

A problem I used to run into was having linked, multi-line article titles allowing an unanchored gap between lines. The problem came and went depending on the font.

In HTML5, you can wrap inline elements around block elements. This means you can wrap article headings in anchor tags.

<a href="#"><h1>The Super Long Article Title</h1></a>

When you do that, the entire block level element (the heading) becomes clickable.

I do it this way on my personal sites now. Use your browser to inspect my anchored post titles.

Bring on the drama, old HTML doctypers.

Author: sdavis2702

I'm a simple guy. I like to code and I like to workout. I'm all about growth and just about everything else is nonsense in my book.

Leave a Reply

Your email address will not be published. Required fields are marked *