CSS Reset or Normalize?

Asked

Viewed 1,988 times

8

I heard about the CSS reset and I am also aware of the Normalize CSS which is a kind of reset for browsers to render basic CSS in a standardized way.

Looking for the best solution in CSS, I wondered: Which to use?

  • Thank you for your time, Dorival! But I was left with a question about his comment: If I use the normalize, and it defines some common characteristics to some of my elements, and then use the reset, and it resets the characteristics, doesn’t it lose some sense? Since one is overwriting the other? I’m sorry if I misunderstood but that’s what it seemed to me.

  • The respect of the superscript is the detail, at this point are usually minimal things like font size of the "h"s or a spacing of "input", which are overwritten, it will not overwrite for example a "box-Sizing" or a "p line-height: 1em". For me they are minimal things that if they are something that really bother you you can remove in the lib of Normalize, but, I recommend that you use this.

  • 1

    Thank you so much for your time and for your great comments, @Dorivalzanetto. I understood and I will then choose to use the 2. Again thank you, helped me a lot!

2 answers

9


The purpose of the reset files to the css are nothing more than, as the name already says, reset the default style that some elements have.

For example, buttons have a gray background, lists have markings on the sides, titles have margins, tables have borders, etc..

All these are native styles of the elements. These reset files will "delete" these styles by OVERWRITING with the css contained in that reset.css.

For example:

button {
    border:none;
    background:transparent;
}

This code css will make the buttons no longer have that style.

Why do this?

The reason for using a reset would be to prevent default properties from interfering with the layout that YOU are creating. If you use a button that has bright colors, etc. It won’t look good with a gray button, or it won’t be the same size. So one of the reasons would be the visual improvement.

Another reason would be the STRUCTURAL IMPROVEMENT. See the image below:

inserir a descrição da imagem aqui

This is a table with the standard style. Besides the look is not attractive, note that it has undesirable edges, which will disturb its structure. To remove these edges, we use a reset to the table.

Which to use?

There is no reset better than the other, not the right one to use, not the restriction of using only one, only another, or even of using more than one at the same time. What you should do is analyze what you need and how much you need to 'clear' the default code. Many of them will create a css for elements that you will often not even use.

I, in particular, have reached the point of not using any preset reset. I myself remove the default styles of the elements I use and need.

To complement your reading, I found these links that seemed interesting:

  • Thank you very much for the reply, now I understand exactly the difference and what to do!

  • I am happy to help! If you have more questions, do not hesitate to ask =D

3

Reset

A reset as its name says will reset all the preset settings of the browsers, this way you can define your own css, without using the features that each browser uses.

Normalize

Normalize as the name says will normalize, that is, it will try to leave the styles standardized in all browsers.

So if you want to define your own css without interference of the rules defined by the browser use reset , if you want to start based on something that already has high compatibility in browsers and add their rules Normalize it will be better.

I leave a complementary literature on the subject:

CSS: reset or normalize?

Forget normalize or resets; lay your Own CSS Foundation

  • So it’s illogical for me to use both, right?

  • @Tiagop. C Exactly, if you use both are overwriting some rules, the reset clears everything. Normalize analyzes all the good rules and keeps them and replaces the bad ones with the good ones, in this case I say good as the most compatible ones in the browsers.

  • Understand, I decided that I will do my own reset, if it works I will keep, in case I have problems with different browsers I opt for Normalize. Thank you @Gabriel Rodrigues for the reply, it was very helpful!

  • @Gabrielrodrigues, I disagree on the point that "if you use both you will be overwriting some rules" this is not a rule, you see, if we really need all the form elements to be standardized, even if a good Reset is elaborated, I’m sure this one will never be as good as Normalize for example, because this second one is made based not only on the best known browsers but on a number of them, some that we may not even know. Already if I need a *{margin: 0}, Normalize does not have by default, so I need to put in a Reset.

  • 1

    Note now, that these are two things that can be used in sets, and highly recommended by large dev. front as the "csswizardry" in the ITCSS documentation, and the override question is not a rule, as I said and sometimes it is necessary to use both for ease of organization and good dev standards. and I do not advise changing third party lib and these often do not meet all our needs. So I advise using both and gave -1.

  • @Dorivalzanetto would be interesting to create an answer with these concepts. from my experience I see that the use of both in a project is not necessary, maybe you can expose the contrary in a reply, thanks for the feedback I read a little about ITCSS found it quite interesting.

  • @Gabrielrodrigues, thank you for the feed, but I have no interest in preparing another answer, considering that I have already expressed the idea to the author of the question and that this question already has two good answers... The comments are more to explain why my Downvote, and I don’t think it’s fair to just vote without making arguments.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.