I see CSS's `unset` as an undo button (CSS #0)

Three CSS lessons. One theoretical, two practical.

Value categories: rough to uniform

There are five different value “categories” that describe values from “roughest form” to “cleanest form, ready to convert to binary”. The value types are: “declared”, “cascaded”, “computed”, “used”, and “actual”.

These last three could’ve been more aptly named to “computed-no-context”, “computed-most-context”, and “computed-full-context” value.

unset: the undo button

Of the four inheritance properties… initial, inherit, unset, and revert… I see unset as an “undo” button. Let’s say you didn’t do anything to border-color. It’s default value is initial. And lets say you didn’t do anything to font-size. It’s default value is unset. Now you have a class called “unset”. In this, it applies unset to both the border-color and font-size. You know what it’ll do? Change it to the default values. What if set it from unset to initial? The font-size would match the default: 16em, however big that is in pixels. The border-color'd be the same. What if you set it to unset to inherit? The font-size'd be the default (pulls from its ancestor), but the border-color'd do something different, it’d pull from its ancestor.

the border matches the color property!

border-color defaults to matching the color property

Fun fact, the default of the border-color, initial, is to match the color property. I found this out when I read this in an example from CSS-Tricks. “The border will become black because, again, that’s what the initial value is” (Omodior, 2020). I tested it in Codepen. When I saw this wasn’t the case, I replied in an annotation: “Not true! The initial value of the border matches the color property!. I changed the color to green, red, indigo, blue, and the border-color always matched in MS Edge v. 89, Chrome, and Firefox.” Nobody thought to change the color property after messing with a descendant’s border-color.

always matched in MS Edge v. 89, Chrome, and Firefox