Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124

Can you write “wrong” CSS?
You regularly find someone who says yes to you, either by saying what I have to do or say what should not do.
For example, his colleagues have argued use reboots, Do not use! Important, do not use shorthand, do not use certain selectors, only to use logical propertiesetc
Others have suggested that you can’t write “bad CSS”. Personally, for he examples given, Have.
Why can’t you write bad CSS?
I present four reasons. (Comment on social media if you think there are more, or that I’m wrong!)
If there is no concrete practical disadvantage, such as a significantly worse user experience or a concretely worse experienced DX, there is no reason to change something that is working. CSS is not occupational therapy.
Additionally, the web platform rarely disapproves of anything and instead emphasizes backwards compatibility. This means that the code is secure. As Pilgrim Mark once said:
Standards are like sex; One mistake and you’ll be stuck rooting for him forever!
There is no bad CSS here.
Suppose there is something extraordinarily wrong with the CSS. For example, your organization is opening to the Arab world and all websites must support RTL scripts.
That is his problem, not that of anyone who promotes the use of logical properties.
It’s your problem, your incentive to solve it, and your decision about when to do what in your CSS. So there is no bad CSS here either.
Now your site uses an old design technique, e.g. float based-, and eventually you don’t like this way of doing the design.
But since we’re talking about CSS—no Presentation HTML—, you can easily change this. “Easily” like making the necessary changes (depending on the project, tests may not run and update as quickly, but this is a different topic).
Therefore, if there is a real need for a change, when one solution is noticeably better than another, the change can always be made.
It’s hard to argue that there’s anything wrong with CSS if CSS allows you to quickly pivot and change the solution, in the sense that it can’t be a serious bug, one that’s hard to fix. we already know what it is The most important thing is to get the HTML correct..
Caution: We’re not there yet. Think of this as a perspective we could put a lot more effort into.
Assuming there is something completely wrong and the CSS you are using is creating problems for your users.
While this may spur action (nothing here says you can’t act), here is where we can make a point that is not often appreciated:
The platform should make it difficult to create barriers and easy to remove them.
This is not an official design principle in our standards and their implementation, but it is certainly one we could adopt.
But what does this say?
That is to say in general terms what Joe Clark, for example, has said in more specific terms (“If a browser or adaptive technology can or should solve an accessibility problem, I won’t do it”):
The developer provides the intent; the platform provides the guarantee of access.
This means that when there is a CSS problem so big that someone would say your CSS is wrong, it might be something that should be addressed at the platform level.
Stay with me here: As quoting Joe may indicate, we’ve been here before, when developers addressed issues that really should have been handled elsewhere. Just one more example? The “notch” where solutions were proposed to solve a problem that we as developers probably shouldn’t need to solve (however, the lack of resolution of which could easily be called “bad” code).
More interesting may be a simplified extreme case: imagine someone using black text on a black background. Inaccessible (and meaningless). What this point suggests is that even that wouldn’t be bad CSS, but that the ability to remove such barriers is the platform’s responsibility. This could happen in several ways: user styles as we already have them, through automated color correction or through some way that a user can toggle to access the content.
let me know If this might be helpful for further discussion, I’ll try to address this topic in a separate article.
Then first, check the context and if it applies to you. For example, if you join a team working on an international website that supports multiple scripts, you may be asked to use logical properties. That’s sound. That’s ok.
So if the context applies to you, consider the advice.
If not, you are still free to accept it, but that is your choice.
The context will tell you whether this is advice or dogma.
(Similarly, you can use all of this to moderate your own criticism of other people’s CSS: is it really “wrong”, i.e. does it not work and they wouldn’t even bear the consequences?)
_ In the end, CSS allows us to solve endless design and interaction problems in countless different ways. The platform controls how these forms are applied, exposed and managed. Because of both, there’s really nothing “wrong” with CSS.
Many thanks to Shaded Ahmed for reviewing this post.