DEV Community

Cover image for Why Most Developers Fear CSS
Steffen Pedersen
Steffen Pedersen

Posted on

Why Most Developers Fear CSS

When I started at my job, we where two front-end developers at my team. It was me and a senior front-end developer. Then the senior front-end developer quit his job, I was the only front-end developer at my team. And it was fine. I did my job, and there was no harm. We had some job interviews, but we did not meet the right fit. The time went by, and then it hit me: I was the only one knowing anything about our front-end. The bus factor was at one, which is not a good number in this case. Why? If I get hit by a bus, the project will be in a bad situation.

I then talked to my boss, and we came to the agreement, that we all should be responsible for the front-end. The work could be done in pair programming. At least until we would find the right match. I thought that was a great idea. I had a total burnt out from working alone on the front-end.

We then presented the idea, and the first reacting was fear from the other developers. The fear was mostly concerned about CSS.

HTML and CSS is for losers ๐Ÿ™„ We should all use Microsoft Word.

โ€” Steffen ๐Ÿ–ค (@mrsteffenp) June 8, 2019

Why do developers fear CSS?

I talked to the other developers about why they fear CSS. The first thing brought up was cascading ๐Ÿ˜ต What if they make changes to one class, that will effect five hundred other elements?

The next thing brought up was support of browsers ๐Ÿ’ป What if they implement something, that isn't supported in some browsers?

The final thing was building something from the ground up ๐Ÿก What if they make something, that isn't solid and doesn't look good?

Cascading ๐Ÿ˜ต

This is one of the biggest fears. When other developers are talking about this, I guess they are talking about many things. It is both importance, specificity, source order and how properties inherit from different rules. The styling can be specified in many different places, and it can interact in complex ways. This is why CSS is so powerful, but it is also the reason why, it can be confusing and difficult. The cascading can be a devilish thing, if you donโ€™t know the rules of how selectors can overrule other selectors ๐Ÿ˜ˆ

Importance

This is a well talked subject. We all know, that it is (in most cases) bad to use this little helper. This is because !important will always win ๐Ÿ†

Specificity

Specificity is basically a measure of how specific a selector is. Like, inline styling is the most specific, then #id, then .class, and then the element. From there, the specificity can be measured in a million different ways. If you have doubts, you can use a specificity calculator.

Source order

Source order is basically that later rules will win over earlier rules. If you write a selector with a property and a value, and then later on write the same selector with the same property - but with a different value. What will then happen? ๐Ÿค“

Inheritance

Inheritance in CSS is both simple and tricky. It can be explained in this way: Some property values applied to an element will be inherited by the element's children, and some won't. Doesn't that sound great? ๐Ÿ˜ต CSS properties like font-size and color do inherit, and properties like margin and padding donโ€™t inherit. I guess that you will have to use common sense in this one. If margin would be inherited, it would cause a huge mess! You could use MDN as reference.

Browser support ๐Ÿ’ป

Unless your client is a company that only support Internet Explorer 6, you shouldnโ€™t worry that much. Most users are using modern browsers with great support of CSS. If you feel insecure whether you should use a specific property, then you can check it out at caniuse. If a browser doesn't support the property, but you really want to use it, then most browsers @supports the CSS at-rule of the same name. Then you can make a fallback solution.

@supports (display: grid) {
  div {
    display: grid;
  }
}
Enter fullscreen mode Exit fullscreen mode

Building something from the ground up ๐Ÿก

This is mostly about the communication between designers and developers. The communication is not always that great. Sometimes the ambitions of the designers can be too high in relation to the company's wallet and the developers' skills - or what is actually possible.

The point is, that we as developers should be more integrated in the design process, so we all can fell comfortable with the outcome. With that being said, if the developer feels comfortable with the design, then it will be easier building it from the ground up.


I hope this wasn't a bunch of nonsense. I just really want to tell other developers, that doesn't work with CSS on a daily basis, that CSS isn't magic โœจ

Thank you for your time!

If you liked this, then please โค๏ธ and follow me on Twitter.

Latest comments (54)

Collapse
 
adilmae profile image
adilmae

it's about time before we see another system to replace it..

Collapse
 
nailsonlinux profile image
Nailson Landim

I see CSS much alike iptables rules.

Collapse
 
minid profile image
Minide

Actually, the main problem of CSS is the metodologies we use to develop. They force us to do mistakes and technical debt. Over the time, anything becomes unmaintainable. That's where the functional CSS shines all over you minid.net/2019/04/07/the-css-utili...

Collapse
 
mohammadhaydar0 profile image
Mohammad Haydar

CSS is magic and I love it. but it's not rocket science.

Collapse
 
techiev2 profile image
Sriram Velamur

This is a lovely read Steffen. Thanks for it.

As someone who has been kept away/kept myself away from CSS, can vouch for both how easy and how important it is to understand stuff like specificity/cascading after building something from scratch with plain grids and mental models of the concepts above.

Good job :)

Collapse
 
bbarbour profile image
Brian Barbour • Edited

Man, I feel like the opposite, with design Since I don't have someone handing me a design, coming up with or thinking of one is hard. I'm comfortable with very basic designs, and those will get the job done, but they don't really stand out.

I guess it's a weakness I hope to shore up. But, I often feel caught between where to spend my time. Learn more design oriented skills, or more programming oriented skills. Never enough time in the day, I suppose. It sucks.

Collapse
 
katsanos_george profile image
George Katsanos
Collapse
 
prahladyeri profile image
Prahlad Yeri • Edited

The biggest fear comes from the fact that debugging or troubleshooting isn't easy with CSS especially when complex layouts and things like floats and transformations are involved.

Add to that the fact that you can have responsiveness, various levels of styling (external sheets, <style> tag, element property) and browsers can also have subtle differences in rendering, it easily gets mind numbing!

Front-end debugging with html/css is still an evolving science compared to back-end debugging which is quite straightforward in comparison.

Collapse
 
orimdominic profile image
Orim Dominic Adah

This certainly was worth the read. Very true, especially the part about changing something somewhere an it affecting many other parts. Even though I had these fears, I really couldn't have put them into words as you've done. I just use frameworks and learn enough to do what I want that those frameworks I use don't do.

Now I know what my exact fears are, I can face them

Collapse
 
steffenpedersen profile image
Steffen Pedersen

Thank you so much ๐Ÿ˜ƒ

Collapse
 
fengerzh profile image
Buzz Zhang

I'd prefer they fear CSS rather than writing lots of !important.

Collapse
 
steffenpedersen profile image
Steffen Pedersen

Thank you for the feedback. I will reduce the amount of emojis in the next article. I was going for a more informal tone.

Collapse
 
ut4utc profile image
ut4utc

was helpful. I did not know about @support, although I constantly work with css, there is nothing complicated at all (well, except for the latest fashionable innovations such as transition and others, where you can already just program the interface behavior - yes, itโ€™s confusing and complicated if you donโ€™t constantly practice track the latest trends.

Collapse
 
leob profile image
leob

What I disliked most about CSS was layout, but with Flex and so on that's improved a lot. But before the modern layout techniques (and even still, I have to confess), I often had a hard time understanding why my layout was broken. Even when looking at Chrome Inspector it often wasn't clear who or what was the cause!

On the other hand I'm surprised to hear that cascading is such a big deal, because most devs are familiar with inheritance as a concept.

Nowadays what I fear about CSS is its sheer complexity, just the huge size of the "API surface".

Collapse
 
cschliesser profile image
Charlie Schliesser

I'm finding more and more new developers see CSS as voodoo. At first this didn't make sense to me, but the points you bring up are the root cause. If you didn't cut your teeth on inline style attributes, and then get CSS support, and then start working on old browser compatibility bugs... a lot of it just doesn't make sense. It's almost a series of stepping stones, and those of us that experienced them when they were laid know what to look out for โ€“ everyone else is just constantly getting "gotcha'd" and it's got to be very offputting.

Collapse
 
mikeschinkel profile image
Mike Schinkel

I am a backend developer and I have no fear of CSS. I just find CSS to be a horrific fractal of bad design (yes, I stole that phrase from elsewhere.) It is a damn shame that those who designed CSS did not have more foresight.

So I am a backend developer by choice because I would prefer to spend my time building buildings rather than digging holes in quicksand. #justsaying

Collapse
 
steffenpedersen profile image
Steffen Pedersen

How is CSS bad designed?

Collapse
 
mikeschinkel profile image
Mike Schinkel

Lack of ability to encapsulate. Working with CSS on even a moderate sized website is like programming a large complex application in a programming language that only supports global variables. Which is bad with one developer, but far worse when there are many working on the same project.

Thread Thread
 
steffenpedersen profile image
Steffen Pedersen

You are able to encapsulate. I often use the architecture ITCSS with naming convention BEM ๐Ÿ˜ƒ I use it at a large company, and it's easy for other developers to wrap their head around the concepts.

Thread Thread
 
mikeschinkel profile image
Mike Schinkel

Actually, you are not able to encapsulate in CSS. What you are talking about is like the ostrich sticking its head in the sand so it cannot see its potential attackers. But its potential attackers can still see it.

The problem with "encapsulation" in CSS is it only works when everyone on the project uses it and uses it the same way. There is no way in CSS for me to write a "module" (for lack of a better word) that someone else cannot override and break with later CSS.

Yes, if you are using CSS you should absolutely employ (something like) ITCSS and BEM, but those are merely ways to reduce the pain of the symptoms of the disease, they do nothing to cure the disease itself.