css global properties best practise?

Viewed 38

below these three code snippets which one would be the best one to implement in a style sheet ?

  *{
      box-sizing:border-box;
      margin:0;
      padding:0;
    }
    
    html,body
    {
    box-sizing:border-box;
      margin:0;
      padding:0;
    }
    
    html
    {
    box-sizing:border-box;
      margin:0;
      padding:0;
    
    }
1 Answers

The asterisk selector * applies to all elements, not just the html/body element. You should avoid this, since you could be writing rules for a div later on and you wouldn't be able to give it any margin or padding (or change its box-sizing)! Use either the 2nd or 3rd snippet depending on whether you want to give the body any margin or padding.

Related