Skip to content

It's Curious How Forgotten and Mistreated CSS Is

Published:

CSS

A few days ago I commented on Twitter and on LinkedIn, that the article with the most views I’ve had this year was one where I did some reviews of CSS Books. So far so good, I’m just sharing that there’s some interest in those book reviews that talk about CSS 😊.

The trigger that led me to write this article was a comment made by my professional colleague Hèctor, where he commented with the phrase that gives the article its title.

It's curious how forgotten and mistreated CSS is

Why don’t people like CSS?

Honestly I don’t know, I do love it, the only thing I can think of is that they don’t know it.

As a species, we have brains designed to reject the unknown. As a race, we have the facility to criticize or despise what’s unknown.

I feel unable to judge a programming language, CSS isn’t one… I see you coming (but we’ll talk about that when CSS Houdini is more advanced), they were created and designed to solve a specific problem, at a specific moment. Something that many people have a dislike for, the cascade, had its reason when CSS was born to style web content. And there’s no point in criticizing it, if you know how it works and the reason why this functionality (it’s not a bug) was decided to be implemented in the language, you’ll know how to leverage it in your favor and how to avoid it when necessary.

I can’t say that “put your favorite language here” doesn’t work, is poorly thought out or doesn’t resemble this or that language I’m used to. I can’t criticize something I don’t know.

Why do they forget about CSS?

I don’t know either. There’s a lot of training that ignores or glosses over CSS topics. It’s curious to see bootcamps that have a web development training program and in the curriculum the weight of CSS content is scarce or non-existent.

There’s so much hype with JavaScript, and it’s well deserved, that it overshadows CSS. Which is curious because CSS is part of the web.

I’ve seen in much code, CSS properties that contradict the previous property or unnecessary properties.

Flexbox

This is code I’ve seen several times in Pull Requests.

<section class="wrapper">
  <div>...</div>
  <div>...</div>
  <div>...</div>
</section>
.wrapper {
  display: flex;
  flex-direction: column;
}

With display: flex we make the <div> elements flexible, but since we want them to display one below the other, flex-direction: column has been added. But attention, that would be the default behavior of <div> elements, there’s no need to add flexbox in this case.

Knowing CSS, we’ll know that we don’t have to add display: flex by default, and we’d know that it would be very useful for controlling spacing and alignment between elements, changing their behavior between different media queries or changing the presentation order, where it would make sense to add it.

!important

The use of !important is beyond our control, more than 27 million in public repositories on GitHub.

!important has its use, it’s necessary and won’t disappear. But using it incorrectly will bring us problems in maintaining that code. Remember, if you have to add an !important something is wrong, sometimes it’s because you’re using a framework or plugin that has behavior you don’t want, which raises the question: do you really need that plugin or framework if it doesn’t meet your needs? But well, that’s another debate.

CSS is Part of the Web

Wanting to develop any solution with web technology implies knowing HTML, CSS, JavaScript and Web APIs. Defining yourself as FrontEnd, but not wanting to touch CSS, in my opinion, that person is not frontend.

#CSSisPartOfTheWeb

Dissemination and Support for CSS

Not everyone has to disseminate about CSS (I’ll continue doing it), but no one should despise it. After all, they are solutions that other people have decided on as a solution to a specific problem, at a given moment.


Previous Post
I Prefer PostCSS
Next Post
Detect AVIF Support for Your CSS Images