Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are two solutions posted on that page. The one with lower votes I would recommend if possible. </p> <p>If you are using HTML5 then it is perfectly valid to put a <code>div</code> inside of <code>a</code>. As long as the div doesn't also contain some other specific elements like other link tags.</p> <pre><code>&lt;a href="Music.html"&gt; &lt;div id="music" class="nav"&gt; Music I Like &lt;/div&gt; &lt;/a&gt; </code></pre> <p>The solution you are confused about actually makes the link as big as its container div. To make it work in your example you just need to add <code>position: relative</code> to your div. You also have a small syntax error which is that you have given the span a class instead of an id. You also need to put your span inside the link because that is what the user is clicking on. I don't think you need the <code>z-index</code> at all from that example.</p> <pre><code>div { position: relative; } .hyperspan { position:absolute; width:100%; height:100%; left:0; top:0; } &lt;div id="music" class="nav"&gt;Music I Like &lt;a href="http://www.google.com"&gt; &lt;span class="hyperspan"&gt;&lt;/span&gt; &lt;/a&gt; &lt;/div&gt; </code></pre> <p><a href="http://jsfiddle.net/rBKXM/9" rel="noreferrer">http://jsfiddle.net/rBKXM/9</a></p> <p>When you give <code>absolute</code> positioning to an element it bases its location and size after the first parent it finds that is relatively positioned. If none, then it uses the document. By adding <code>relative</code> to the parent div you tell the span to only be as big as that.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload