Preferences

that hasn't been a thing since xhtml. html5 did away with /> for tags that don't have a closing tag. like img, meta, br, etc.

xhtml was never supported by all major browsers. You couldn't do stuff like <div/> and get away with it.

Not sure why the the self closing tags became widely used

> Not sure why the the self closing tags became widely used

For a while adhering to the open/close conventions helped use tooling / libraries built around the assumptions for XML in dealing with HTML, maybe up through the late 00s/early 10s.

Any utility gains there faded as HTML5 conventions and libraries became more solid, but I still have a bit of the habit, especially with <img/> & <br/>.

Some editors had trouble with color coding non-compliant xhtml. At least that was my reason for doing it. (In the very early 2000s)
> xhtml was never supported by all major browsers.

Source? https://caniuse.com/xhtml says otherwise

> You couldn't do stuff like <div/> and get away with it.

I just tried on both Firefox and Chromium, they parse it properly.

When xhtml was popular internet explorer was a major blocker for using it properly. I never saw xhtml served with the proper content type at the time.

I don't see a reason to mix html and xhtml today. It will only lead to problems. (I.e using self-closing tags and &amp; mismatches in urls)

If you use <div/> in html the browser will just ignore the end / See https://jsfiddle.net/sw8j9fo2/

This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal