No p element in scope but a p end tag seen.w3c validation

Sam IR picture Sam IR · Jan 13, 2014 · Viewed 33.1k times · Source

My HTML is as as below. I have opened all elements and closed them. Still when I check it on w3c it shows error. 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>

Answer

Mr. Alien picture Mr. Alien · Jan 13, 2014

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