Reputation: 3411
My goal:
To use css to select the html tag with 2 different selectors based upon class.
My issue:
It seems as though the HTML tag can't be selected with a class as well on CSS.
What I have Tried:
Option 1:
.light-theme html {
background: #fff;
}
.dark-theme html {
background: #000;
}
Option 2:
html .light-theme {
background: #fff;
}
html .dark-theme {
background: #000;
}
Option 3 (hack to get around original issue:
.light-theme {
background: #fff;
}
.dark-theme {
background: #000;
}
My results:
Option 1 and Option 2 do not work at at while Option 3 work fine, but never includes the HTML as a selector.
My question:
Is it even possible to use classes as a css selector for the html tag using css?
Upvotes: 1
Views: 67
Reputation: 3678
html.light-theme {
background: #fff;
}
html.dark-theme {
background: #000;
}
html.light-theme
means select html
tag with class light-theme
Upvotes: 2