Skip to content

Instantly share code, notes, and snippets.

@cr0ybot
cr0ybot / how_to_organize_css.md
Last active January 29, 2026 22:13
How to Organize CSS

How to Organize CSS

Just use Sass (SCSS specifically).

The actual most important rule is to co-locate styles for a selector, which is easier with Sass than without. The "traditional" method of placing all styles for a particular breakpoint in a single @media query at the bottom of the file (or eve worse, a different file entirely) is a good way to end up with spaghetti CSS that is difficult to override and impossible to maintain without introducing regressions.

Consider an everyday task for a CSS developer: "Go make the logo bigger/smaller on X screen size". How do you figure out where to put the new/changed styles? I suspect you might inspect the element in your browser to see how it displays at certain screen sizes, and then you go look for the selector (likely a class name) in the codebase. What happens if there are 12 results for .logo? Now you have to go scrolling around in the code to figure out which ones are nested inside of media queries in order to find the right place. Or maybe you just gi

Prompt:

I'm building a custom WordPress block for testimonials. I want you to write the PHP, JS, and HTML with an a11y-first approach. Assume a screen reader and keyboard-only user. Include screen reader text where appropriate, proper heading levels, semantic structure, and aria labels only if they’re absolutely necessary. Explain any a11y tradeoffs you make. Use WordPress best practices throughout.

Rules:

🔒 Prompt Template: "A11Y-First WordPress Development"