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.