Close all HTML elements
As you might remember from our previous lessons, some HTML elements, like <br>
or <img>
, are self-sufficient and don't require an end tag. However, the World Wide Web Consortium (W3C) strongly recommends closing all HTML elements that do have an end tag. Reasons for this include more enhanced readability and a cleaner markup.
Besides, one day, you may write code in XHTML, which is another markup language. It's more flexible for processing different data formats but also stricter when it comes to rules. This means browsers may not display the page correctly if the code contains unclosed tags.
From Lesson
HTML Dos and Don'ts