Jump to content

Close paragraph tags cause validation errors


jwermont
 Share

Recommended Posts

I have a simple file that almost passes HTML 4.01 Strict validation, except for two errors: two closing paragraph tags that are flagged as 'end tag for element "P" which is not open.'The tags are like so:

      <p class="outer paragraph">        <p class="inner">         Stuff....        </p>        <p class="inner">         More stuff....        </p>   </p>

It's the final </p> that's caught as an error. (I got two errors because there was another piece of the code similarly structured.)The close tags for the inner paragraphs were not flagged as errors. When I removed the two outer close tags, the page validated.Here are the real pages:http://home.sonic.net/~jwermont/portfolio/...v/samples2.html - doesn't passhttp://home.sonic.net/~jwermont/portfolio/...ev/samples.html - passesI don't understand this. Doesn't HTML 4.01 require close tags for all tags? Are nested paragraphs not allowed? Is there a bug in the validation? Could somebody explain this?Thanks!Joyce

Link to comment
Share on other sites

It is illegal to have a <p> within a <p> tag.Code should be:

       <p class="inner">        Stuff....       </p>       <p class="inner">        More stuff....       </p>

Or

       <div class="outerparagraph">       <p class="inner">        Stuff....       </p>       <p class="inner">        More stuff....       </p>       </div>

Link to comment
Share on other sites

You could also use <span> I think.The differance is <div> displays as block-level element, <span> inline I think.

Link to comment
Share on other sites

you guys are all exactly correct :)i'll just add that spans can be used for a small amount of text, but you can't nest them within each other.divs have ultimate nestability

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...