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
and padding
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 a size
shorthand can’t set the inline-size
, and the inset
shorthand doesn’t include inset-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.
Continue Reading →