Shadow DOM and Style Encapsulation
A native browser mechanism for attaching an isolated DOM subtree to an element, preventing styles and markup from leaking in either direction.
Shadow DOM is the specific piece of the broader Web Components spec responsible for genuine style and DOM structure isolation, letting you attach a separate, encapsulated DOM subtree — a 'shadow tree' — to a host element, whose internal contents are invisible to regular DOM queries and CSS selectors on the main page, and vice versa. Even outside of full custom-element usage, understanding Shadow DOM matters because several native browser elements (like <video>'s built-in controls, or <input type="range">'s slider) are themselves implemented using it internally.
Shadow DOM is like a hotel room with its own thermostat and decor completely separate from the building's shared HVAC and hallway decorations — the room's internal style choices don't leak into the hallway, and the hallway's paint job doesn't seep into the room, except for a few explicitly shared utilities (like the building's central water supply, similar to CSS custom properties) that both sides deliberately agree to share.