logoalt Hacker News

peststoday at 3:55 AM0 repliesview on HN

> And a <div> is just a <span> with display block…

It's a bit more subtle than that. HTML5 defines "Content Models", two of which are 'Phasing Content' and 'Flow Content'. Phasing Content can only contain text and text-like tags (em, strong, bold) whereas Flow Content can contain anything.

Technically <span> is defined as accepting Phrasing Content and <div> accepts Flow Content. Changing this with CSS doesn't change the content model.

Although browsers are very forgiving so it all works anyways and this is very in the deep end, I can't think of the last time I've consciously thought of this stuff.

https://html.spec.whatwg.org/#the-span-element

https://html.spec.whatwg.org/#the-div-element

https://html.spec.whatwg.org/#content-models