Keep shared design values in one place, reuse simple component classes, and isolate genuine page-specific rules. Inspect the cascade before adding another override. Refactor one component at a time, compare its states and screen sizes, and keep the old version available. A smaller stylesheet is not a success if a working layout or control breaks.
How do you find the CSS that actually controls an element?
Start with a visible problem or a repeated component, such as a service card. In browser DevTools, inspect the element and its Styles and Computed panels. Record the winning declaration, the file and line that supplied it, and any inherited value. Crossed-out declarations are clues that another rule won; they are not proof that a rule is unused everywhere.
The cascade considers more than selector specificity. Origin, importance, cascade layers, scope where applicable, and source order also matter. Appending a stronger selector or !important may hide the symptom while making the next edit harder.
Inventory the stylesheets loaded by representative pages. Check whether a theme file, component file, inline style, or third-party widget controls the result. Use the DevTools troubleshooting workflow when the source of a style is unclear.
Which values should become shared design tokens?
Start with values that intentionally repeat: brand colors, text colors, spacing steps, content width, and border radius. CSS custom properties make these decisions named and reusable. Keep the first set small; naming every one-off measurement creates busywork.
:root {
--color-ink: #172033;
--color-accent: #1d4ed8;
--space-card: 1.25rem;
--content-width: 72rem;
}
.service-card {
color: var(--color-ink);
padding: var(--space-card);
border: 1px solid #cbd5e1;
}This is a small illustrative pattern, not a replacement theme. Compare the original appearance before substituting values. Custom properties usually inherit, so a value set on a section can affect descendants. A token name does not establish accessible contrast; check the actual foreground and background combination.
How should a modest stylesheet be arranged?
- Foundations: box sizing, body text, links, and shared custom properties.
- Layout: content containers, grids, and spacing relationships.
- Components: buttons, cards, navigation, forms, and callouts.
- Page-specific rules: exceptional layouts under a clear page class.
- Responsive and preference rules: the corresponding component’s narrow-screen, reduced-motion, print, or other supported variants.
You can keep this structure in a single small stylesheet or split it into a few meaningful files. File count is a maintenance decision, not a quality score. Avoid creating a separate file for every minor rule when it makes the site harder to follow.
A class such as .service-card expresses a reusable component. A page-scoped selector such as .project-page .project-gallery expresses a specific exception. Long selectors coupled to exact nesting often break when the HTML changes. Avoid broad rules such as article a if they unintentionally restyle every button, breadcrumb, and linked card.
Should you add cascade layers or a framework?
Cascade layers can make priority between groups of styles explicit, but adopting them is a deliberate migration. For normal author declarations, unlayered styles take precedence over layered ones. Moving only a few rules into a layer can therefore change which existing rule wins. Important declarations have different layer precedence, another reason to review the cascade rather than guess.
A utility framework or component library can help a team with a consistent development process. It can also introduce a build step, new conventions, and dependency upgrades. For a small plain-HTML site, start by cleaning up the existing structure. Adopt a tool when it solves a real repeated problem and someone can maintain it.
Do not mix a wholesale restyle with a structural cleanup. A change that is supposed to preserve appearance should have an easy comparison against the prior version.
What is a safe one-component refactor?
Example: three versions of a service card
List the pages and states where the cards appear. Capture narrow and wide screenshots. Identify shared padding, title styles, and link behavior. Create one shared class, then use a clearly named modifier such as .service-card--featured only for a real variant. Replace one page’s old rules and compare it before touching the next page.
Keep the card’s heading level, link text, focus indicator, and reading order intact. A CSS cleanup should not silently turn the whole card into an inaccessible click handler.
Search JavaScript and templates before renaming a class; scripts may use it to find elements or attach behavior. After each step, inspect the diff and run the site’s existing checks. Use a preview and a separate commit so the cleanup can be reverted without undoing unrelated content work. Delete an old rule only after searching its use across the whole project and testing relevant states.
What should the finished cleanup prove?
- The same component uses the same shared class across the intended pages.
- Desktop, mobile, hover, focus, expanded, error, and disabled states still work where relevant.
- Long text and zoom do not hide content or create new sideways scrolling.
- There is no unexplained increase in selector specificity or new global override.
- Any removed rule has been checked beyond a single screenshot.
- The published page loads the intended stylesheet version.
If the source is correct but the live design still looks old, follow the stale website change checklist. If the layout itself fails on small screens, use the mobile layout repair guide rather than stacking additional overrides blindly.
Sources and further reading
- MDN: Cascade, specificity, and inheritance
- MDN: Using CSS custom properties
- MDN: Cascade layers
- Chrome DevTools: View and change CSS
Documentation checked October 6, 2026. Examples illustrate a workflow; they are not measured client results or guarantees.
Build on a clear website foundation
This free article extends the beginner workflow with a focused technical topic. If you need the starting process, BUILD • PUBLISH • OWN IT is a 44-page beginner PDF guide for $99.99 USD covering a ChatGPT, GitHub, and Cloudflare website workflow. Review its contents to see what the PDF includes; this article does not promise that every technique here is covered there.
Colby will personally assist if you get stuck following the guide. Additional hands-on work may carry a fee, with the scope and price agreed before work begins. Applicable tax is shown at checkout, and third-party service charges are separate. Read the purchase terms for details.