skip to Main Content

I have an index page with a list of articles that each should link to their corresponding article page. However in the title of each article there can also be hashtags (similar to twitter/instagram hashtags) that should be separately clickable.

I know HTML5 does not allow links inside links, or any interaction for that matter. I also know Google much prefers a shorter explanatory link text above a block link full of elements.

What would be the best way to handle this, keeping valid HTML5 and also with SEO in mind.

so to briefly put in code:

<article>
 <a href="/link_to_article">
  <h1>Title of article <a href="/search/#hashtag">hashtag</a></h1>
  <p>Some brief text</p>
 </a>
</article>

Perhaps I should reside to javascript for the block-level link? Interested to hear your opinion.

2

Answers


  1. Because of writing valid code, I would recommend use of javascript onclick param. Something like onclick=”location.href=’/link.html'” on the outer div wrap. Don’t wrap block elements like h1, p, div, … with an inline element/a-tag.

    Login or Signup to reply.
  2. Just make them separate links.

    <article>
      <h1>
        <a href="/link_to_article">
          Title of article</h1>
        </a> 
        <a href="/search/#hashtag">hashtag</a>
      </h1>
      <p><a href="/link_to_article">Some brief text</a></p>
    </article>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search