Dos & Don'ts For Resetting CSS

deyrupak

Rupak Dey

Posted on February 14, 2021

Dos & Don'ts For Resetting CSS

Why reset CSS ?

Main reason is to fix any inconsistencies with default styles between different browsers.

Save It For Later! Let's begin...

1. DO reset box sizing

* {
   box-sizing : border-box;
}
Enter fullscreen mode Exit fullscreen mode


2. DO reset margins & paddings

* {
   margin : 0;
   padding : 0;
}
Enter fullscreen mode Exit fullscreen mode

or

body {
   margin : 0;
   padding : 0;
}
Enter fullscreen mode Exit fullscreen mode


3. DO reset form elements

button,
input,
optgroup,
select,
textarea {
   font-family : inherit;
   font-size : 100%;
   line-height : 1.15;
   margin : 0;
}
Enter fullscreen mode Exit fullscreen mode


4. DON'T remove list styles

āŒ

ul, li {
   list-style : none;
}
Enter fullscreen mode Exit fullscreen mode

instead remove from specific elements within
āœ…

.navigation {
   list-style: none;
}
Enter fullscreen mode Exit fullscreen mode


5. DON'T remove focus styles

āŒ

:focus {
   outline : none;
}
Enter fullscreen mode Exit fullscreen mode

instead you can change it's style
āœ…

:focus {
   outline: none;
   box-shadow: 0 0 0 2px #565663;
}
Enter fullscreen mode Exit fullscreen mode


They are definitely useful for consistent styling & also gives you a clean slate to work with.

Do you use reset CSS in your projects?
Share your thoughts and let's chat in the comments!


P.S. Want the next post to be on something specific? Do let me know in the comments.

šŸ¤˜šŸ»


Connect with me : Github | Tutoring | Freelance Web Dev

šŸ’– šŸ’Ŗ šŸ™… šŸš©
deyrupak
Rupak Dey

Posted on February 14, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Dos & Don'ts For Resetting CSS
css Dos & Don'ts For Resetting CSS

February 14, 2021