Knowledgebase

Organising and Maintaining Stylesheets Print

  • webdevelopment, performance, guide, howto, solution, zillionkinghost, hosting, support
  • 0

Structure at scale.

WHAT GOES WRONG WITHOUT ORGANISATION

Styles nobody can find Rules nobody dares remove Escalating specificity as overrides accumulate The same value defined in dozens of places

WHAT TO ESTABLISH

A structure: reset or base, then layout, then components, then utilities

A naming convention A set of defined values for colour, spacing and type

WHAT TO ORGANISE BY

Component.

WHY

Components are reused; page-specific styles are not.

WHAT TO AVOID

Deeply nested rules Overrides upon overrides Styles applied by document position

WHAT PREPROCESSORS AND MODERN CSS PROVIDE

Variables, nesting and composition.

WHAT TO BE CAREFUL WITH

Nesting deeply, which produces high specificity invisibly.

WHAT TO REMOVE

Styles for components that no longer exist.

WHY

Unused styles accumulate and slow every page.

WHAT TO AUDIT

How many distinct colours, sizes and spacing values exist.

WHAT YOU WILL FIND

Considerably more than intended.

WHAT TO DOCUMENT

The conventions, so others follow them.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot