DEV Community

Discussion on: Is CSS objectively bad?

Collapse
 
moopet profile image
Ben Sinclair

The biggest problem people have with CSS is that it's not strictly coupled with HTML. There's no contract saying that inside a div with class foo you're allowed to present a p tag but never an a tag. This isn't XHTML and there's no DTD here.

And there's no way to brute-force test every permutation. So QA are going to keep finding bugs, because they'll order the round of -99 beers at the bar.

It's not solved by making bigger and bigger frameworks which require you to restructure your HTML and to add more and more divs and classes into the soup.

It's not solved by splitting everything into components and adding your styles with Javascript, because while with one eye that looks like a reasonable separation, the other eye sees the mountain of change requests queued up in your future.

It is partially solved by sticking to semantic markup. It is partially solved by having a universal styleguide, and having your designers in on the deal, where they can make things consistent.

True story: once I built a site used by ~400k people where the designers made each page different - blue heading, all caps on white on one page, lowercase white on blue on the next, that sort of thing. They kept within their palette and so on but that was about it. I asked them why and they replied that they didn't want the site to look like it was using a CMS.

Objectively bad bits:

  • no DTD
  • Forcing manual or snapshot-comparison testing
  • HTML is a document, with flow, not a window manager - everything relates to everything else

I'd put the problems of things like box-sizing right at the bottom of the list.

Collapse
 
stereobooster profile image
stereobooster

The biggest problem people have with CSS is that it's not strictly coupled with HTML. There's no contract saying that inside a div with class foo you're allowed to present a p tag but never an a tag. This isn't XHTML and there's no DTD here.

I like your direction of thought. But at the same time, from layout/paint engine point of view, this is a bunch of rectangles to draw... The problem from my point of view is "global-ness" of CSS selectors (by tag name, nested selectors, specificity, inherited/not inherited properties).