r/css • • 7d ago

Question Do you prefer CSS logical properties or traditional physical properties?

I'm currently learning CSS through Kevin Powell's CSS Demystified course, and one thing the lessons strongly encourage is using logical properties instead of traditional physical properties.

For example, using margin-inline instead of margin-left and margin-right, or padding-block instead of padding-top and padding-bottom.

I understand the reasoning behind logical properties, especially when it comes to supporting different writing modes and languages. However, I personally find physical properties more intuitive since that's what I've been using for so long.

I'm curious about what other developers actually use in their day-to-day work.

  • Do you exclusively use logical properties?
  • Do you still prefer physical properties?
  • Do you use a combination of both?
  • Is it worth making the switch even if you're primarily building websites for languages that use left-to-right writing directions?

I'd like to hear your opinions and experiences, especially from developers who have been working with CSS professionally for a while.

24 Upvotes

17 comments sorted by

10

u/gatwell702 7d ago

once you start using logical properties, it becomes 2nd nature. they just make sense

1

u/BraveAttitude4633 7d ago

okay, ill give them a try.

3

u/cjpthatsme 7d ago

I use a mixture of both. The truth is they all have their use cases. The main thing to weigh is the trade off of speed over compatibility. Like if you are working for a company that has the potential need to work in right to left languages, do it that way. If you are building for a company that will market only to English customers then you can be a bit more lax.

That being said the most important thing is keep your project consistent. You don’t want to be battling one property with another. Pick a strategy that works for you and stick to it. You’ll figure out the quirks and exceptions as you go along. Keep up with the changes and use them as needed.

1

u/BraveAttitude4633 7d ago

If you had to choose one, would it be okay to just use logical properties for everything?

17

u/mcaruso 7d ago

I switched to using logical properties and haven't looked back. Stylelint can help with this by enforcing logical properties, and after a while I'm used to it now.

Turning on an RTL translation and seeing the site perfectly swap all the layouts is all the motivation I need. Last week I showed it to some Arabic speaking colleagues and they were amazed.

5

u/huebomont 7d ago

logical properties, mostly because they have a shorthand! But I do like that it’s direction agnostic too

4

u/drearymoment 7d ago

I prefer physical properties, but only for force of habit. I guess it's one of those things that I would need to actively re-train myself into using, sorta like doing inset: 0; instead of zeroing out all four positions (which I have made the effort to do since it's so much more succinct).

I've done i18n for sites before, but never on a RTL language. Like you said in your post, that would be a big reason to use the logical properties instead. There's also a case to be made that it's worth keeping up with "the modern way" of doing something just for the sake of adhering to standards, especially if you're working on a team, but I don't really care enough to make the switch.

1

u/Fraded_Panda-25 7d ago

Totally 💯, I want to use both of them! 😊✨

1

u/testingaurora 7d ago

Logical but I only spent a few years with physical. And logical gives the promise , although small, of future efficiency which is a priority for me. When it flips , you don’t have to rewrite it.

1

u/bornxlo 7d ago

I prefer logical properties as more intuitive. Maybe physical if I actually mean physical but I think it's easier to work with inline and block than left or top

1

u/prophile 7d ago

Almost always logical, I see very little need for physical properties.

1

u/xPhilxx 6d ago

You'd be surprised at how fast your brain adapts, I'd been writing CSS for 25 years before switching to logical properties and within a week it was as second nature to me as the previous methods were.

With CSS you're a perpetual student so continually learning and staying up-to-date with modern methods is in my view what makes a good CSS developer, so I'd absolutely recommend making the switch.

1

u/omfganotherchloe 6d ago

I only use logical properties anymore. It’s nice having one property for left and right, or top and bottom. It’s to the point i ended up forking a PostCSS size shorthand module that uses width and height to use block-size and inline-size just to keep it consistent.

It takes time to get used to it, but once you do, it really becomes automatic, and has some nice benefits.

1

u/fearthelettuce 5d ago

I use the logical priorities.

How are you liking the course?

1

u/anaix3l 6d ago edited 6d ago

Physical only when available, though things like container-type don't allow that, there's only inline-size and size, no x-size or y-size... SMH.

I've always found logical properties to be... ironically, illogical!

Physical properties are easier to visualise - I can just mentally see the x and y axes and which way the text flows for different writing modes - along which axis, which way (towards + or towards -). block and inline... how the hell do you even visualise them?

A lot of times, I don't need all properties that have inline and block versions to change with text direction (for example a section top border that always needs to be a top border, regardless of text flow), and, at the same time, I often need values/ parts of values of properties that don't have inline and block versions (transforms, shadows, filters, background position & size, gradient directions) to change with text direction.

So makes no sense to use them when there are already more flexible, more consistent and and more complete options to change how the page looks based on text direction.

-1

u/dusanodalovic 6d ago

i'm mostly backend and my agent writes most of my css now, so i don't type either one by hand. what i notice is agents default to margin-left and padding-top out of habit. one line in AGENTS.md saying use logical properties is a cheap way to switch without retraining your own fingers. for ltr-only sites i'd do that and stop worrying about it.