Is it acceptable to use h2, h3, p, div tags inside anchors (a / a)?

13

Is it acceptable in SEO and semantics to use tags like <h2> , <h3> , <p> and <div> within <a href=""></a> ?

I noticed that to make items on a page people usually use a structure similar to this:

<div class="item">
    <a href="produto/1">
        <figure>
            <img src="images/produto-1.jpg" alt="produto 1">
        </figure>
        <h2>Produto</h2>
        <p class="price">R$ 1000</p>
    </a>
</div>

I know that the <a> tag is inline and needs display: block to work, but the question really is about SEO and semantics.

    
asked by anonymous 11.01.2016 / 15:49

2 answers

12
  

Is it acceptable to use tags <h2> , <h3> , <p> , <div> within links / anchors ( <a></a> )?

Yes. This is an HTML5 feature . Other versions did not allow this use.

On the contrary (put <a> within <h1> , <h2> , etc.) is the most used until today. There are several examples. one of the most notable, in my view, is the GitHub documentation. Hovering over a title, an image of an anchor containing the full link to that anchor appears.

    
11.01.2016 / 16:17
11

In the <a> tag specification in Permitted elements HTML5 The following elements are supported and are supported semantically if they do not change the original behavior of <a> :

>  <a>, <abbr>, <address>, <article>,
> <aside>, <audio>, <b>,<bdo>, <bdi>, <blockquote>, <br>, <button>,
> <canvas>, <cite>, <code>, <command>, <data>, <datalist>, <del>,
> <details>, <dfn>, <div>, <dl>, <em>, <embed>, <fieldset>, <figure>,
> <footer>, <form>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <header>,
> <hgroup>, <hr>, <i>, <iframe>, <img>, <input>, <ins>, <kbd>, <keygen>,
> <label>, <main>, <map>, <mark>, <math>, <menu>, <meter>, <nav>,
> <noscript>, <object>, <ol>, <output>, <p>, <pre>, <progress>, <q>,
> <ruby>, <s>, <samp>, <script>, <section>, <select>, <small>, <span>,
> <strong>, <sub>, <sup>, <svg>, <table>, <template>, <textarea>,
> <time>, <ul>, <var>, <video>, <wbr>

Link Recommended SOEN: Is putting a div inside an anchor ever correct?

    
11.01.2016 / 16:18