liveBook · Manning

Reset style sheet

As explained in Web Design Playground, Second Edition

A CSS reset is a stylesheet technique that removes or normalizes browser-default styling so authors can establish consistent starting styles.

A reset style sheet clears browser-supplied styling so you can start styling from a predictable baseline. Browsers quietly add defaults such as margins and padding; useful at first, perhaps, but less charming when you want full control of a page’s appearance. section 9.5 section 19.10

The basic idea is simple: remove defaults first, then add the spacing and visual design you actually want. Without replacing the removed spacing, content can sit tight against the browser window, so a reset is a fresh start rather than a finished design. section 9.5

A small reset can do three useful jobs:

  • Remove default margins, preventing browser-added outer space from deciding the layout for you. section 19.10
  • Remove default padding, leaving you to set interior space deliberately where it is needed. section 9.5
  • Set box-sizing: border-box, as part of a consistent starting rule for element sizing. section 9.5 section 19.10

For a short page, the universal selector, *, is the quick all-elements option. It applies one rule to every element, which is unusual for ordinary styling but handy when every element needs the same clean slate. section 19.10

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

Use this compact reset near the top of a style sheet. It removes margins and padding everywhere, then lets later rules restore just the space each part of the page needs. section 9.5

From edge-hugging to intentional space

Resetting a navigation bar’s margins can make it run close to the top and sides of the browser window. Add margins back to the navigation list and surrounding content to create the breathing room you want, instead of inheriting it by accident. section 9.5

For larger or more serious projects, a professional reset such as Normalize.css can provide a more consistent default across browsers. The goal is not to make everything plain forever; it is to spend less time wrestling with browser defaults and more time designing the page. section 9.5

A project baseline

A portfolio-page layout begins with a reset that sets margin and padding to 0 and font size to 100%, before Grid and Flexbox rules shape the page. The reset prepares the ground; the layout rules do the decorating. section 20.5 section 20.5

How Web Design Playground, Second Edition covers it

How deep it goes
Explains margin, padding, and border-box resets with small rules, while deferring detailed cross-browser reset design to Normalize.css.
Examples
Uses a universal-selector rule, a reset element list, an edge-hugging navigation bar, and a portfolio-page baseline.
What it assumes
Introduces the reset through plain CSS declarations while relying on basic awareness of elements, margins, padding, and style sheets.
What you can do after
Apply it via CSS rules to remove default spacing and establish a deliberate starting point for page styling.
How it connects
Connects CSS resets to the universal selector, margins, padding, box-sizing, CSS Grid, and Flexbox.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground, Second Edition. The section links point to the parts of the book it draws on.