Search code examples
htmlw3c

Validation: end tag for element "P" which is not open


The Following Code i wrote will not pass the W3C validator, instead it will give me the following Error:

Line 18, Column 7: end tag for element "P" which is not open

Its the closing </p> tag imediately after the </ul> tag. And im realy having trouble to nail the problem down. Here is the markup:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="de">
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>foo</title>
    </head>
    <body>


    <div class="foo1">
        <div class="foo2">
            <h1>some heading</h1>
                <p>
                    <ul>
                    <li>some stuff</li>
                    <li>yet another stuff</li>
                    </ul>
                </p>
                <p>yet another heading</p>
        </div>
    </div>
    </body>
    </html>

Solution

  • Ul not allowed in <p> Tag in Html 4. better try like this.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
        <html lang="de">
        <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>foo</title>
        </head>
        <body>
    
    
        <div class="foo1">
            <div class="foo2">
                <h1>some heading</h1>
    
                        <ul>
                        <li>some stuff</li>
                        <li>yet another stuff</li>
                        </ul>
    
                    <p>yet another heading</p>
            </div>
        </div>
        </body>
        </html>