kamil
kamil

Reputation: 3522

W3c Validator HTML 4.01 Transitional - whats wrong here?

Here is my piece of code which gives me error:

<ul>
<li>
    <div><span>Text</span></div>
    <div>
        <ul>
            <li>
              <a href="#">
                <div>Link</div>
              </a>
            </li>
        </ul>
    </div>
</li>
</ul>

An error:

document type does not allow element "DIV" here; missing one of "APPLET", "OBJECT", "MAP", "IFRAME", "BUTTON" start-tag

Upvotes: 0

Views: 197

Answers (2)

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167250

You cannot have a div (block element) inside an a (inline element).

<a href="#">
    <div>Link</div>
</a>

Upvotes: 2

Quentin
Quentin

Reputation: 944546

<div> elements are not allowed inside <a> elements (until HTML 5 which doesn't use DTDs and supports the transparent content model).

(The DTD allows applet, object, map, iframe and button inside a elements, and it allows div inside all those elements, but the specification forbids the combination of those two factors in the text, it is a limitation of DTDs which is why the valdator suggests that as a fix).

Upvotes: 4

Related Questions