Monday, June 16, 2025
No menu items!
No menu items!
HomeDesigningSome HTML is “Optional”

Some HTML is “Optional”

There is a variety of HTML that you can just leave out of the source HTML and it’s still valid markup.

Doesn’t this look weird?

<p>Paragraph one.
<p>Paragraph two.
<p>Paragraph three.

It does to me, but the closing

tags are optional. The browser will detect it needs them and manifest correctly in the DOM anyway.

This probably happens to HTML you write and you don’t even know it. For example…

<table>
  <tr>
    <td></td>
  </tr>
</table>

That looks perfectly fine to me, but the browser will inject a

in there around that

for you. Optional in HTML, but the DOM will put it in anyway.

Heck, you don’t really even need a in the same fashion! Jens Oliver Meiert shares more:

<link rel=stylesheet href=default.css>

Some attributes are “optional” too in the sense that they have defaults you can leave out. For example, a

RELATED ARTICLES

Most Popular

Recent Comments