There’s a bit of a blind spot when working with CSS logical properties concerning shorthands. Miriam explains:
Logical properties are a great way to optimize our sites in advance, without any real effort.
But what if we want to set multiple properties at once? This is where shorthands like
margin
andpadding
become useful. But they are currently limited to setting physical dimension. Logical properties are great, but they still feel like a second-class feature of the language.There are a few 2-value shorthands that have been implemented, like
margin-block
for setting both the-block-start
and-block-end
margins. I find those extremely useful and concise. But the existing 4-value shorthands feel stuck in the past. It’s surprising that asize
shorthand can’t set theinline-size
, and theinset
shorthand doesn’t includeinset-block-start
. Is there any way to update those shorthand properties so that they can be used to set logical dimensions?
She ends with the money question, whether we can do anything about it. We’re currently in a position of having to choose between supporting flow-relative terms like block-start
and inline-start
with longhand properties and the ergonomic benefits of writing shorthand properties that are evaluated as physical terms like top
, bottom
, left
, and right
. Those of us writing CSS for a while likely have the muscle memory to adapt accordingly, but it’s otherwise a decision that has real consequences, particularly for multi-lingual sites.
Note that Miriam says this is something the CSS Working Group has been working on since 2017. And there’s a little momentum to pick it up and do something about it. The first thing you can do is support Miriam’s work — everything she does with the CSS Working Group (and it’s a lot) is a labor of love and relies on sponsorships, so chipping in is one way to push things forward.
The other thing you can do is chime into Miriam’s proposal that she published in 2021. I think it’s a solid idea. We can’t simply switch from physical to flow-relative terms in shorthand properties without triggering compatibility issues, so having some sort of higher-level instruction for CSS at the top of the stylesheet, perhaps as an at-rule that specifies which “mode” we’re in.
<coordinate-mode> = [ logical | physical ] or [ relative | absolute ] or ...
@mode <coordinate-mode>; /* must come after @import and before any style rules */
@mode <coordinate-mode> <stylesheet>
selector
property: value !<coordinate-mode>;
Perhaps naming aside, it seems pretty reasonable, eh?
Direct Link →