While I understand that :root
can be used to select the html
tag in an HTML file and the svg
tag in an SVG file, I personally find it strange and not practical to apply the same styles to both HTML and SVG using :root
. It seems like an unrealistic scenario to me.
The only legitimate use of :root
that I have come across is to override styles set for html
, as pseudo-class selectors take precedence over type selectors. However, I believe it is best to avoid frequent overrides of html
styles and instead link specific CSS files later in the document.
Therefore, my question is: are there any real-world scenarios where using :root
would not just be a peculiar alternative to selecting html
(or svg
for SVG files)?