Sobes.tech
Junior

What is the difference between reset.css and normalize.css?

sobes.tech AI

Answer from AI

reset.css resets almost all browser CSS styles to a minimal default value. The goal is to eliminate differences in the default display of elements between browsers, starting from a "clean slate." This may require more effort for subsequent styling.

normalize.css also eliminates differences between browsers but does so more selectively. Instead of resetting, it tries to preserve useful default styles and only corrects those that cause inconsistencies. It is easier to use because it retains some basic semantics.

Here are the key differences:

Feature reset.css normalize.css
Purpose Reset all styles Normalize basic styles
Style preservation No Yes, useful styles are preserved
Basic semantics Lost Preserved
Required effort More, for styling from scratch Less, some styles are already present

Example of reset.css (simplified):

/*
  Resets margin, padding, border, outline for all elements.
*/
* {
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  font-size: 100%;
  vertical-align: baseline;
  background: transparent;
}

Example of how normalize.css corrects the display of strong and b:

/*
  Fixes incorrect display of `strong` and `b` in some browsers.
*/
b,
strong {
  font-weight: bolder;
}