I’ve just been doing some experiments with font-weight for my latest project that is soon to be released. It appears it’s another prime example where browser vendors have spectacularly failed to implement an incredibly vague and woolly W3c CSS spec, causing a messy, ugly, time consuming birdsnest of behaviour.
The behaviour specifically is regarding the keywords: “lighter”, “normal”, “bold” and “boldest” , now the trouble really stems from the fonts themselves, which have no formally recognized weighting system and use the keywords
“Regular, Roman, Book, Medium, Semi- or DemiBold, Bold, or Black”
to describe their relative darkness.
GREAT. That makes things easy then, so we’ll just rely on the W3C to give us a scale from 100 to 900 that maps these possible darkness to one of the increments of numbers (although it fails to mention why 100-900 was chosen?A random whim?), hmm, wait a minute, that means the keywords “lighter”, “bolder” and “bold” mean bugger all as they’re totally inconsistent from font to font. Apparently normal is “synonymous” with 400 and bold is “synonymous” with 700 but “synonymous” isn’t much fr*cking use, as in the world of computers we need ACTUAL CONSTANTS to be able to do anything robustly programmatic with them.
ARGGGGGGGGG!
So to further this I decided to conduct some tests with a javascript test page to see what I got from the different browsers. You can see the test page here and the results are pasted into this file here.
To summarise, it’s a total mess, the webkit browsers seem consistent but completely at odds with the spec, saying almost everything is “normal”, firefox 2 & 3 does a weird behaviour where it makes lighter and bolder 1 (enter random boldness unit here) thing higher than the synonymous “normal”, in a kind of perverse trick, IE6, 7 and opera all seem to interpret the spec as one might expect (have I jumped into some kind of parrallel universe where Microsoft got something right - cue argument about 5.5’s box model was correct…) and have implemented it so lighter is 100, normal is 400 and bold is 700.
So forget font-weights returning something consistant cross browser, they’re obviously another CSS property that was deemed unimportant enough to care about. Thanks browser vendors, you’ve just wasted two evenings of my time.
