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; }

15th Jul 2020, 1:38 PM
Sainath Dora
2 Answers
+ 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.
15th Jul 2020, 1:48 PM
123
+ 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
15th Jul 2020, 1:49 PM
Hanuma Ukkadapu
Hanuma Ukkadapu - avatar