HTML & CSS · Junior · Question 50 of 75

How does the dark: variant work by default in Tailwind v4?

Explanation

By default dark: relies on prefers-color-scheme. For a manual theme toggle, the variant is overridden with @custom-variant dark (&:where(.dark, .dark *)); - then the theme depends on a dark class on an ancestor. Tailwind doesn't consider the time of day.

Further reading

Problem with a question

HTML & CSS · Junior · question 50

Test yourself

Take the HTML & CSS · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz