VoidKing
VoidKing

Reputation: 6412

Is there a CSS selector for ALL elements in a page?

I am familiar with the asterisk used as a wild card in CSS.

My question is: Is there a CSS selector for absolutely ALL (I mean html, body, along with every single descendant, direct or otherwise) elements of a page?

I have tried:

*
{
    color: green; /*Used this just to test and see if it worked, but didn't*/
}

Is this possible in CSS?

Please don't ask why I want to do this, LOL :)

Upvotes: 0

Views: 595

Answers (1)

user2129623
user2129623

Reputation: 1256

The * universal selector does select every element, including the root <html> element and all of its descendants.

You can also combine them like * * which would select the child of the root element ( <body> ) and all of its descendants and * * * to style the next generation and all of its descendants.

Or you can style only the grandchildren and below of a div: div * * {color: lemonchiffon;}

Example

Upvotes: 5

Related Questions