← Back to Blog

Optional closing elements

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

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

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.