Optional closing elements

Last updated February 11, 2022 by Jacob Paris

Several HTML elements do not require closing tags

  • <html>
  • <head>
  • <body>
  • <p>
  • <dt>
  • <dd>
  • <li>
  • <option>
  • <th>
  • <tbody>
  • <tr>
  • <td>
  • <tfoot>
  • <colgroup>

That means that this is valid html

<head> <title> My blog </title>
<h1> My blog </h1>
<p> Welcome to my blog
<p> Here are a list of my posts
<li> My first post
<li> My second post
<li> My third post

As a general rule I don't recommend writing html like this, as it can be hard to tell when an element is meant to end or meant to nest, especially when the formatting isn't as clean as possible.

There's a dozen or so HTML tags which optional closing tags, so this is legitimate valid HTML markup