-
Notifications
You must be signed in to change notification settings - Fork 707
[css-values] A more reasonable unit for letter-spacing
#1814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can definitely see where you're coming from, a really common rule in a lot of my stylesheets looks something like: h1, h2, h3, h4, h5, h6 {
letter-spacing: -.02em;
font-weight: 600;
line-height: 1.2;
} It seems I'm often thinking about /* Stripe Text Shadow */
.stripe {
font-family: 'Teko', sans-serif;
color: black;
text-shadow: white .02em 0 0,
white 0 .02em 0,
white -.02em 0 0,
white 0 -.02em 0,
black .06em 0 0,
black .06em .06em 0,
black 0 .06em 0,
black -.06em .06em 0,
black -.06em 0 0,
black -.06em -.06em 0,
black 0 -.06em 0,
black .06em -.06em 0,
white .08em 0 0,
white .08em .08em 0,
white 0 .08em 0,
white -.08em .08em 0,
white -.08em 0 0,
white -.08em -.08em 0,
white 0 -.08em 0,
white .08em -.08em 0;
} But before a new unit gets proposed, what about using CSS Custom Properties (CSS Variables) to let any author abstract their own units for properties like <div>KERN</div>
<style>
:root {
--nudge: 0.01em;
}
div {
font-size: 24pt;
letter-spacing: calc(-2 * var(--nudge));
}
</style> In this example I've set a global CSS variable called P.S. I want to say the same thing to the 'Pi Radians' person in this thread, but I'm a too scared to suggest a solution like this over there 😵: <div>You turn me right round</div>
<style>
:root {
--pirad: .5turn;
}
div {
transform: rotateZ(calc(-.25 * var(--pirad)));
}
</style> Do you see how CSS variables put authors in control of their own 'scale' for using units? |
You should not be scared, but variables are intended for stuff that is very specific to one site, which these units are not. Custom |
Yes, it's definitely possible to address in various ways:
(out of which I still prefer I also don't believe in sprawling specs that define every possible unit of measurement, but a |
This would be extremely useful if this unit would always match the unit used in the font itself, i.e. if all fonts had 1000 UPM (units per em). However, different fonts have different UPM values (as mentioned in Jukka's answer in one of the StackOverflow issues referred above), so mapping the hypothetical |
We're allowing percentages in |
Yes, I would say that’s a satisfactory resolution, plus it neatly solves the inheritance issue. |
The
letter-spacing
property is commonly used to make micro-adjustments to typography, so in practice you'd mostly see minuscule fractions such as0.015em
, or-0.05em
s. Wouldn't the relative unit of 1/1000em that Adobe products use be more expressive for the vast majority of cases? A milliem (mem) of sorts, if you will. Other than personal experience (I've never tracked anything >= 1em), people seem to be asking about this: 1 2 3The text was updated successfully, but these errors were encountered: