Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to validate HTML5 (e.g. unclosed <p> tags)

I'm used to teaching others about the importance of writing good html code, by forcing them to use the http://validator.w3.org for checking if they forgot to close a tag.

This works great when using xHTML1 Strict, but I'd like to use the HTML5 doctype and tags where possible.

The validator does not report opening a <p> tag without closing it to be an error.

Is this normal in HTML5 or is the validator not working properly?

like image 339
Jorre Avatar asked Feb 19 '23 02:02

Jorre


1 Answers

The validator is likely working correctly:

A p element’s end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, dir, div, dl, fieldset, footer, form, h1, h2, h3, h4, h5, h6, header, hr, menu, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is not an a element.

From: http://www.w3.org/TR/html-markup/p.html

like image 110
Brad Lord Avatar answered Feb 23 '23 07:02

Brad Lord