Why is it not recommended to use the asterisk in css "reset" operations?

Asked

Viewed 122 times

4

I’ve seen several internet tutorials on css reset teaching that one should never use the asterisk to apply the modifications.

For example:

* { margin:0; padding:0; }

But, along with the statement that doing so is problematic, I’ve never seen an explanation of why can’t you do that.

Why is the use of the asterisk in css not recommended? Is there any risk?

  • 1

    Maybe by performance, but it varies too much. Is there an example where you read this?

1 answer

3

Using " * " you are selecting ALL the elements of HTML, which doesn’t make much sense. An example: the tag <p> by nature already comes with a margin-top and a margin-bottom setados, if you remove these spaces very likely you will need to add them again later, since they are the default spaces of the paragraph, and without them the texts will be pasted.

The reset is to leave the elements more "pure" possible, removing any influence from the browser or some other trace of CSS. It should not apply to all elements.

That’s what I think, right.

Browser other questions tagged

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