HTML tags must not be forgotten to close

Time:2021-11-30

Building web pages that conform to web standards has always been a topic discussed by jb51.net. Then, do you remember to close all XHTML elements? Some elements in HTML do not need to be closed. When the next element starts, the previous element is automatically closed. This is not allowed in XHTML. All elements must be closed, even if there is nothing in them (such as < img >). Such page editing meets web standards.

Error:
<li>Item 1
correct:
<li>Item 1</li>

Error:
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
correct:
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>

Error:
<br>
correct:
<br />

Error:
<img src=”image.jpg” alt=””>
correct:
<img src=”image.jpg” alt=”” />

Wrong practices should be 100% avoided. As always, always keep all your tags closed.