What’s the difference between :root and * selector in css. Doesn’t both of them do the same thing?
No, :root
is the root element, the toppermost element in in the DOM tree - it’s <html></html>
if it’s an HTML page (but not if it’s an SVG or XML document)
*
just means “select everything”: * { padding: 0; }
would set padding to 0 on every element.
3 Likes