CSS Logical Properties: A good use case

preview_player
Показать описание
CSS logical properties specifies width/height/padding/border/etc using inline + block instead of top + bottom.

But where is that actually useful?

Heres a good example I just ran into with writing-mode: vertical-rl;
Рекомендации по теме
Комментарии
Автор

The important consideration is that people may translate your website to a non left-to-right script. So it doesn’t really matter that someone’s website is in English and only in English. If a visitor translates it to Arabic, which is right-to-left, the layout will be broken unless the website uses logical properties.

Автор

They are also useful for setting padding or margins on two sides instead of just one, without having to specify or override others.

A good use case is having margin-inline: auto (left and right for horizontal writing modes) and then only adjusting margin-block for specific elements and not having to worry about either setting top and bottom or accidentally breaking the left and right margins.

IainSimmons
Автор

You keep blowing my mind with these Wes insanity

quintennn
Автор

Do you think that I always should use logical properties?

yyydollars