DEV Community

Discussion on: What makes CSS so hard?

Collapse
 
efpage profile image
Eckehard

Mybe it´s worth looking back to the roots of CSS.

HTML and CSS have been invented in a time, where networks had a very limited capacity and people used acoustic modems on a telephone line to access the internet. HTML some features to make documents more readable (like headlines and bold face) with a minimal overhead, but you could not even use color (because people at CERN had only monochrome displays).

To make document more readable, CSS was the perfect solution. Instead of adding format information to every part of the document, CSS simply changes how the machine works: You only define once to make all headlines red, not for every headline you use.

This was really efficient so save bandwidth, but gave you some headache if you need special formatting for a single item. That is where the trouble starts: You need to define some qualifiers like id´s in HTML and use them in CSS (or - if you like - define some classES in CSS and use it in HTML). That gives you a serious amount of overhead, if you want to apply CSS to a single element and makes things hard to maintain. You can use inline styles instead, but that makes it even harder to maintain. And - may have some serious unwanted side effects too.

CSS has some serious design flaws. Most of all:

  • definitions and identifiers always have a global scope (except inline styles).
  • styles are evaluated in a very special way. The larger your ecosystem is, the harder it will be to determine, which style is finally applied to an element.

There have been several attempts to solve this, but most of them seem to solve one problem but give you two new headaches.

The only thing you can say about CSS is: It is like it is. I´m pretty sure that - if somebody had to invent a new internet from scratch on a current hardware - things would look very different from what we see today.