Validation Error <h3> tag

  • Thread starter Thread starter Izi
  • Start date Start date

Izi

Izi

Soldato
Joined
9 Dec 2007
Posts
2,718
Getting error:
document type does not allow element "h3" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag

Code:
<h2>LATEST BLOG ENTRIES</h2>
    
        <a href="link"><h3>texttexttext</h3></a>
        <h4>25/11/2009</h4><br />
        texttexttexttext
    
        <a href="link"><h3>texttexttext</h3></a>
        <h4>23/11/2009</h4><br />
        texttexttexttexttext

What am I missing?
 
put <h3> outside your <a> tags:

Code:
<h3><a href="x">text</a></h3>

This - because a link can be a word or phrase within a heading, but you'd never want a link that incorporates an entire heading AND something else*.


* awaits exception challenge...
 
You might be better off using a list too.. style it with CSS to remove the bullet points etc (li {list-style-type: none;})


Code:
<h2>Latest Blog Entries</h2>
<ul>
	<li><a href="link" title="short description..">25/11/2009 - texttexttext</a></li>
	<li><a href="link" title="short description..">23/11/2009 - texttexttext</a></li>
</ul>
 
Technically it's invalid because <a> is an inline element and <h3> is a block element (i.e. it appears on a new line by default). An inline element isn't supposed to contain a block element.
 
Back
Top Bottom