0
What is the difference between * and body tag in css
What is the difference between *{ Margin:0px; Border:2px solid red; } Body{ Margin:0px; Border:2px solid red; }
2 Antworten
+ 1
body is an element selector (selects an element body) while * is a universal selector (selects all elements).
The body selector has higher priority, but the * selector applies more broadly, so in <body>foo<p>bar</p></body> the bodyselector will determine the background of the text foo, but the * selector will determine the background of the <p>element.
+ 1
Sainath Dora
* - Is called universal selector
- Selects everything - every element in the document
- Can come in handy while applying a common style to every element.
body - selects only the body element