© Carlos Rojas 2021
C. RojasBuilding Native Web Componentshttps://doi.org/10.1007/978-1-4842-5905-4_4

4. Shadow DOM

Carlos Rojas1 
(1)
Medellin, Colombia
 

In this chapter, you are going to get acquainted with Shadow DOM, another specification in the set of Web Components. You will learn what Shadow DOM is and how to use it in web components. Next, we will build a new web component for our collection.

What Is Shadow DOM?

The Shadow DOM specification defines a mechanism with which to encapsulate our web components. The markup and styles that we create inside our web components protect it from external DOM manipulation and lobal CSS rules.

Consider, for example, the HTML 5 <video> tag. If we want a video player in our document, we create something similar ...

Get Building Native Web Components: Front-End Development with Polymer and Vue.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.