I often see web developers use the following:
*, html {
margin: 0;
padding:0;
}
But I would have thought that would be redundant, since * matches all elements. Am I missing something here?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It isn’t redundant if you are in need of more specificity to protect from an override default style on an
htmlselector maybe such as in the case of changing font styles.However,
*will match anhtmltag.You can read more about CSS Specificity here.
Edit:
Example case usage:
if you have a default set of styles you include on every page to override browser defaults that includes this:
then later a different css file happens to have the same selector for a different case:
Then your
htmlwill remain unaffected because a*has no specificity for starters which means the rule is overturned by the previous css rule.I added a font changing example that does this on the
bodytag to demonstrate the concept – http://jsfiddle.net/M89Tn/1/