Hacker News new | ask | show | jobs
by detaro 2272 days ago
The definitions for the default styling are in CSS, not in HTML: https://drafts.csswg.org/css2/sample.html
1 comments

Thank you for pointing that out! <samp> does indeed have a default font-family of monospace there.

And <code> isn't defined at all! I'm not disputing this is all internally consistent or that I used to write what I'm now learning is incorrect HTML, this completely explains what I used to know about the tags and I love it:

I didn't know or forgot <samp> was a thing for whatever reason. I know HTML5 is big and I don't know it all, HTML4 is much less so and I usually do.

I always prefer <pre> when I'm writing HTML to show intentionally-monospace blocks like code or code output because <code> is inconsistent, importantly for me it meant sometimes it didn't|doesn't work. Here I now know why: The CSS2 stylesheet doesn't define anything for <code>!

Other replies have described how it makes more literal/semantic sense to nest these things together and I agree completely; many times I am surprised at how elegant these old specifications are, if indirectly.

from that link:

    pre, tt, code,
    kbd, samp       { font-family: monospace }

?
I agree, looks like I misread it -- then some of this is still a mystery that's probably left to how things like Netscape and Internet Explorer used to work. Too bad!