Skip to content

Latest commit

 

History

History
52 lines (34 loc) · 1.67 KB

README.md

File metadata and controls

52 lines (34 loc) · 1.67 KB

62. Maintainability refactor

Improve a growing stylesheet without changing behavior.

Learn

  • duplicate rules
  • specificity debt
  • token extraction
  • module boundaries
  • regression checking

Build

Refactor an older project and compare screenshots before and after.

Check your work

  • Open the result in a browser and inspect the HTML and computed CSS.
  • Test at narrow and wide widths and use the keyboard for interactive elements.
  • Write down one thing you changed after testing.

Deep lesson

How it works

Maintainability refactoring changes structure without changing intended behavior. Extract repeated values into tokens, reduce duplicated rules, simplify selectors, and move page-specific styles closer to their component. Work in small steps so each change can be compared visually and functionally. A screenshot comparison, keyboard pass, and targeted browser check can catch regressions.

Common mistake

Large unreviewed rewrites make it hard to know which edit caused a regression. Removing a selector because it looks redundant may change a hidden state.

Guided challenge

Choose an older lesson page. Refactor its CSS in three small commits, compare before and after at two widths, and explain each structural improvement.

Completion check

  • Rebuild the core idea without copying the example line by line.
  • Explain the key HTML or CSS choice in your own words.
  • Test the result at a narrow width and with keyboard navigation where relevant.

Run the example

Open example.html in a browser. Edit style.css, save, and refresh.

Try: Duplicate a value, then refactor it into a custom property without changing appearance.