HTML – is closing li tag required?

HTML li tag can be used inside ul or ol tags. Its closing tag is optional and it makes html more readable and less verbose. So it can be safely omitted. Here is what spec says:

An li element's end tag may be omitted if the li element is immediately followed by another li element or if there is no more content in the parent element.

Example – li tag without closing tag

<ul>
<li>item1
<li>item2
</ul>
refresh

Specification

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments