Luke Hansford

C
S
S

CSS

🌱 Seedling1 min read

Organizing

I.e. where exactly to place CSS rules. I don't personally have a strong preference at the moment, though I'm somewhat persuaded by this argument for ordering alphabetically. I tend to follow the following structure though:

  • Element selectors at top, classes at bottom (I don't tend to use ID selectors).
  • Variations on rules (e.g. media queries, hover states, etc.) are underneath the "main" rule.
  • I like to use CSS modules where possible, so most component specific styling should be co-located with the component code.

Linked notes

Webmentions

No one has interacted with this page yet.