To Close or Not to Close
matsimon.dev·9h·
Discuss: Hacker News
🎨Design Tokens
Preview
Report Post

Have you ever wondered if it’s better to “close” a br or input tag like <br /> or if it’s better to just write <br> in HTML5? Or why it’s not correct to write <script src="script.js" />? Well so have I, and my findings on the subject were a lot more interesting than I anticipated (if for some strange reason you find stuff like this interesting).

If you are not interested in the whole story, just jump to the section «Validity» to get your answer.

Random Photo © Mat Simon

Void elements

Void elements are a special kind of element that must not have content. That’s a big difference to other elements that _can_be empty but can also contain other elements and text (such as <div>s)...

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help