Home > Designing, Others > Some HTML is “Optional”

Some HTML is “Optional”

September 11th, 2019 Leave a comment Go to comments

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…


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

Categories: Designing, Others Tags:
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.