Search code examples
htmlw3c-validation

How to resolve "No p element in scope but a p end tag seen" error in W3C Validation?


My HTML is as as below. I have opened all elements and closed them. Still when I check it on the W3C's validation service, it shows an error about "No p element in scope but a p end tag seen"

I cant figure it out.

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Untitled Document</title>
    </head>
    
    <body>
        <p>
            <div class="inr_content clearfix">
                 <div class="col2 first fl">
                      to provide a drive-in services.
                 </div>
                 <div class="col2 last fr">
                      to provide a drive-in services.
                 </div>
            </div>
        </p>
    </body>
</html>

Solution

  • That's because you are nesting a block level element inside the p tag which is invalid. You can only nest inline elements such as span, a and img inside p tag. So your markup is invalid, consider making something like

    <div class="inr_content clearfix">
       <div class="col2 first fl">
          <p>to provide a drive-in services.</p>
       </div>
       <div class="col2 last fr">
          <p>to provide a drive-in services.</p>
       </div>
    </div>
    

    From W3C[1] :

    The P element represents a paragraph. It cannot contain block-level elements (including P itself).

    1 - Reference