-1

I am kind of confused between universal selector and body selector now because I need to add

box-sizing:border-box;
Padding:0;
Margin:0;

Where should I keep this in universal selector or in body selector ?? Please clear my doubts.

Peter Krebs
  • 3,831
  • 2
  • 15
  • 29

1 Answers1

1

body selector will add those property to the <body> tag.

body{
  box-sizing:border-box; 
  Padding:0; 
  Margin:0;
} 

But universal selector * will apply those properties in each element of the html content. if the structure is like this.

<body>
<h1></h1>
<p></p>
</body>

when you apply

*{
  box-sizing:border-box; 
  Padding:0; 
  Margin:0;
} 

It'll be applied to each element. like this -

body, h1, p{
  box-sizing:border-box; 
  Padding:0; 
  Margin:0;
} 
Saikat Roy
  • 502
  • 8
  • 20