There is no way to express that in CSS.
The status text inherits its appearance from the global style sheet and does not know font size, family, line height, or anything.
That’s not quite correct. Because text in your status div inherits its values for font-size, line-height, etc. via the cascade, it “knows” these and will style itself accordingly. The problem is that CSS doesn’t offer a way of using these values for calculations. They are only implicitly considered when declaring new properties.
The only way to achieve exactly what you want is via JavaScript. I made a fiddle here using some jQuery. In my example, a simple body declaration acts as the ancestor. Run it with different font-size and line-height values in the body CSS.
In practice, I would combine this with your method as a fallback for scenarios where
- JavaScript is disabled
- the relevant ancestor’s
line-heightis given as a percentage value (descendants inherit the calculated value) and you decide to change your statusfont-size. Example: The ancestor’sfont-sizeis16pxand itsline-heightis120%(~ 19px). Now, if you decide your status needs more attention and declare.progressStatus {font-size: 24px;}, it will inherit the calculatedline-height(still 19px). So you’d have a line-height smaller than the text size. Explicitly declaring aline-heightas in your “half-solution” prevents that case from occuring.