4 ms·
Is that a spec or it just happens?
by antman 6y ago
Is that a spec or it just happens?
- Stratoscope 6y agohttps://html.spec.whatwg.org/ https://html.spec.whatwg.org/
- enriquto 6y agoPart of the spec, and recommender by many people. For some examples of modern html, see google's style guide for html, section 3.1.7 shows an example of a complete and correct document that may blow your mind. Also, the examples of tables and lists without closing elements: https://google.github.io/styleguide/htmlcssguide.html https://google.github.io/styleguide/htmlcssguide.html
- duckmysick 6y agoIt sounds good in theory, but in practice it adds a huge mental overhead. > A p element's end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, 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 an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element. https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission https://html.spec.whatwg.org/multipage/syntax.html#syntax-ta... This is so complicated. In the end it's easier for me to close the tag instead of second guessing if I may skip it or may not.
- enriquto 6y agoIn practice you can always skip the closing p tag. The difference is inconsequential (it only matters for the whitespace).