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.

Browsers give elements default styles, including margins. A reset style sheet clears some of those choices so you can set the spacing yourself. Think of it as clearing the table before arranging everything where you want it. section 9.5 section 19.10

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

This compact reset uses the universal selector, `*`, to apply three declarations to every element: remove margins, remove padding, and set `box-sizing` to `border-box`. Put it near the top of your style sheet, before adding your own spacing. section 9.5 section 19.10

A reset is a starting point, not a finished design. With margins set to zero, a navigation bar can sit tight against the window edges and the text below it. Add margins back where the layout needs breathing room. section 9.5

Give the spacing back

After resetting, give a navigation list its own top, right, bottom, and left margins; give the content below it left and right margins. The browser no longer decides those gaps for you. An initial portfolio-page reset similarly sets margin and padding to zero and font size to 100% before the page layout is styled. section 9.5 section 20.5

For a larger project, a professional reset such as Normalize.css is another option. The important reminder: once you remove default spacing, remember to supply the spacing you actually want. section 9.5

How Web Design Playground, Second Edition covers it

How deep it goes
Shows universal-selector reset declarations and their visible spacing consequences, but defers a professional reset to Normalize.css.
Examples
Uses a marginless navigation bar, restored list spacing, and an initial portfolio-page reset.
What it assumes
Assumes basic CSS styling and margin concepts while explaining what the universal selector matches.
What you can do after
Build it from scratch using a universal-selector reset, then restore needed page margins.
How it connects
Connects the universal selector with browser defaults, margins, padding, and box sizing.

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.