HTML does not require closing tags for certain elements like `<p>`, `<li>`, `<img>`, and `<br>`. This is a common misconception stemming from the XHTML era. In HTML, many elements have optional end tags, and void elements (like `img` and `br`) have no end tags at all. The self-closing `/>`syntax is valid but optional in HTML5, included only for XHTML migration compatibility. While XHTML requires strict tag closure due to its XML basis, HTML has always allowed optional end tags for specific elements. Best practice is consistency: either always close tags explicitly for clarity and team collaboration, or omit optional closures for brevity when you understand the implications for whitespace and layout.
20 Comments
Sort: