Consider the following HTML:
<ul>
<li>
<h2>Item 1</h2>
<p class="subline">Meta information bla bla</p>
<div class="description">
<p>Paragraph one</p>
<p>Paragraph two</p>
</div>
</li>
</ul>
I want to link each of liwith a link. As a proof of concept, I give you this invalid code:
<ul>
<li>
<a href="http://www.google.com/search?q=test+1">
<h2>Item 1</h2>
<p class="subline">Meta information bla bla</p>
<div class="description">
<p>Paragraph one</p>
<p>Paragraph two</p>
</div>
</a>
</li>
</ul>
Obviously, this will not be checked because I cannot have block-level elements inside inline elements.
EDIT: As it turned out, the above code is valid in HTML5. The problem is resolved.
I need to find another solution:
Insert a tag ain each block level item
I considered adding identical tags h2 > a, p.subline > aand div > p > a, but I would like to have a hang state using :hoverthat affects the entire link area, so this will not work.
Using the onclick event
Javascript (li.onclick = function() { window.location.href = ...), . , Javascript , , .
inline:
<ul>
<li>
<a href="http://www.google.com/search?q=test+1">
<span class="title">Item 1</span>
<span class="subline">Meta information bla bla</span>
<span class="description">
<span>Paragraph one</span>
<span>Paragraph two</span>
</span>
</a>
</li>
</ul>
, display: block , .
HTML, .
- , ?