我习惯于通过强制他们使用 http://validator.w3.org 来教导其他人编写好的 html 代码的重要性。用于检查他们是否忘记关闭标签。
这在使用 xHTML1 Strict 时效果很好,但我想尽可能使用 HTML5 文档类型和标签。
验证器不报告打开 <p>
标记而不关闭它是错误的。
这在 HTML5 中是正常的还是验证器工作不正常?
最佳答案
验证器可能正常工作:
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.
关于html - 如何验证 HTML5(例如未闭合的 <p> 标签),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12544859/