Why Most Developers Fear CSS
Tags: css, webdev, productivity
Published: 2019-06-08 20:55:43

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. 

<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">HTML and CSS is for losers 🙄 We should all use Microsoft Word.</p>&mdash; Steffen 🖤 (@mrsteffenp) <a href="https://twitter.com/mrsteffenp/status/1137427569723265025?ref_src=twsrc%5Etfw">June 8, 2019</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

## 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 🏆

<iframe height="265" style="width: 100%;" scrolling="no" title="CSS: Now and the Future - Cascading: Importance" src="//codepen.io/steffenpedersen/embed/VOEVpK/?height=265&theme-id=dark&default-tab=css,result" frameborder="no" allowtransparency="true" allowfullscreen="true"></iframe>

#### 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.

<iframe height="265" style="width: 100%;" scrolling="no" title="CSS: Now and the Future - Cascading: Specificity" src="//codepen.io/steffenpedersen/embed/MdPzVR/?height=265&theme-id=dark&default-tab=css,result" frameborder="no" allowtransparency="true" allowfullscreen="true"></iframe>

#### 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? 🤓

<iframe height="265" style="width: 100%;" scrolling="no" title="CSS: Now and the Future - Cascading: Source order" src="//codepen.io/steffenpedersen/embed/oRamjQ/?height=265&theme-id=dark&default-tab=html,result" frameborder="no" allowtransparency="true" allowfullscreen="true"></iframe>

### 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](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference) 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](https://caniuse.com/). 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;
  }
}
```

### 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*](https://twitter.com/mrsteffenp).