DEV Community

Discussion on: Tell me about the worst CSS you've ever had to deal with

Collapse
 
moopet profile image
Ben Sinclair • Edited

Ok. There's a chance this is still out there, on a site with tens or possibly hundreds of thousands of regular users, so I'm not going to be too specific.

<div id="my-super-specific-id" class="fw-500 big red well-padded non-semantic-utility-class">
  Content
</div>

So the HTML was full of DIVs as text holders instead of proper semantic emelents, full of non-semantic junk utility classes and, importantly, this thing called fw-500. What's that, then?

There were several CSS files with names like grid-768.css, grid-980.css, etc. You can guess what these were for, right? Right. So you'd have media queries in them like so:

/* grid-980.css */
@media (min-width:1024px) {

.fw-1 { width: 1px; }
.fw-2 { width: 2px; }
.fw-3 { width: 3px; }

/* ... */

.fw-767 { width: 767px; }
.fw-768 { width: 767px; }
.fw-769 { width: 767px; }
.fw-770 { width: 770px; }

/* ... */

.fw-1920 { width: 1px; }

}

Yes, there were (usually) 1920 of these lines. I only hope they generated them in the first place rather than typing them by hand, but who knows.

This was a crude column array, down to pixel level, that could be varied depending on viewport size even though you thought you were working only at desktop sizes.

But the filename didn't always match up with the media query it was using, because Things Change.

And then... and then a lot of the sizes had non-matching widths because of off-by-one error fixes or discrepancies between box-sizing in different browsers and so on.