Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML semantics: Is it a good idea to put links (anchor elements) in headings?

Tags:

html

semantics

Is that wrong to build news list this way:

   <h1><a href="article-1.html">That happened!</a></h1>
   <div class="short">Just like planned</div>

Should I prefer this?

   <h1>That happened!</h1>
   <div class="short">Just like planned</div>
   <div><a href="article-1.html">Read it now</a></div>

or remove header elements?

   <div class="news-header"><a href="article-1.html">That happened!</a></div>
   <div class="short">Just like planned</div>
like image 256
dmzkrsk Avatar asked Jan 28 '26 18:01

dmzkrsk


1 Answers

It's perfectly valid to put a link inside a heading. In fact, Stack overflow even does it on every question page. Do whatever makes most semantic sense for the page.

In HTML5, you can even wrap the heading inside the link, like so:

<a href="article-1.html"><h1>That happened!</h1></a>
like image 126
animuson Avatar answered Jan 30 '26 10:01

animuson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!