Normalize vs Reset CSS
Written byPhuoc Nguyen
Category
CSS
Created
23 May, 2020
Each browser provides a set of default styles which are applied for every web pages it renders.
The default style sheet is also known as the user-agent style sheet.
You can take a look at the default styles provided by:
Since the default styles are not the same, causing a web page will have different look and feel on each browser. Both normalizing and resetting CSS aim to fix that problem.
-
Resetting CSS, as the name suggests, will reset all the built-in styles.The most popular CSS reset library is Meyer's reset.css which you can see the complete code here. For example, it resets the
`margin`
for`body`
to 0:body {margin: 0;}If you use the Developer Tool of Chrome browser, and inspect the body element of any web page, you will see that it has the margin of 8px by default which we often don't want to have at all:body {margin: 8px;} -
Normalizing CSS is another alternative to resetting CSS.The most popular library in this area is normalize.css. It tries to make built-in browser styling consistent across browsers.More than that, the library also:
- Makes some elements look like what we expect.
For example, the Chrome, Firefox and Safari browsers use the following styles for the`sub`
and`sup`
tags:sub {vertical-align: sub;font-size: smaller;}sup {vertical-align: super;font-size: smaller;}It's not easy for us to distinguish these tags with normal one visually. normalize.css improves by declaring the position for these tags:sub {bottom: -0.25em;}sup {top: -0.5em;}- Fix display bugs across browsers.
You can look at its source code to see there are lot of bug fixes for different browsers such as Internet Explorer, Edge, Firefox, etc.
You don't need to include normalize.css if you use popular CSS libraries. It's already included in:
#Resources
- water.css adds more visual styles for common tags
- minireset is another tiny modern CSS reset
- This website allows us to get the default styles of various rendering engines for particular element
Questions? 🙋
Do you have any questions? Not just about this specific post, but about any topic in front-end development that you'd like to learn more about? If so, feel free to send me a message on Twitter or send me an email. You can find them at the bottom of this page.
I have a long list of upcoming posts, but your questions or ideas for the next one will be my top priority. Let's learn together! Sharing knowledge is the best way to grow 🥷.
Recent posts ⚡
Copy the content of an element to your clipboard
01 Oct, 2023
Make a text area fit its content automatically
30 Sep, 2023
Quickly insert alternate characters while typing
30 Sep, 2023
Zebra-like background
30 Sep, 2023
Add autocomplete to your text area
28 Sep, 2023
Linear scale of a number between two ranges
28 Sep, 2023
Highlight the current line in a text area
27 Sep, 2023
Create your own custom cursor in a text area
27 Sep, 2023
Mirror a text area for improving user experience
26 Sep, 2023
Display the line numbers in a text area
24 Sep, 2023
Select a given line in a text area
24 Sep, 2023
Newsletter 🔔
If you're into front-end technologies and you want to see more of the content I'm creating, then you might want to consider subscribing to my newsletter.
By subscribing, you'll be the first to know about new articles, products, and exclusive promotions.
Don't worry, I won't spam you. And if you ever change your mind, you can unsubscribe at any time.
Phước Nguyễn