HTML & CSS · Senior · Question 24 of 75

How do you style the inside of a Web Component when Shadow DOM isolates its styles?

Explanation

Outside selectors don't reach into a shadow root, even with !important. But inherited properties (color, font) and custom properties cross the boundary - theming is built on them. The component author can expose parts via part="label", which are styled from outside with my-el::part(label). Slotted content (light DOM) is styled with regular CSS.

Further reading

Problem with a question

HTML & CSS · Senior · question 24

Test yourself

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

Take this quiz