Template, slot, and shadow

The benefit of web components is their re-usability: you can create a UI widget once, and reuse it multiple times. While you do need JavaScript to create web components, you don't need a JavaScript library. HTML and the associated APIs provide everything you need.

The Web Component standard is made up of three parts—HTML templates, Custom Elements, and the Shadow DOM. Combined, they enable building customized, self-contained (encapsulated), reusable elements that can be seamlessly integrated into existing applications, like all the other HTML elements we've already covered.

In this section, we'll create the element, a web component that allows users to rate an experience on a scale of one to five stars. When naming a custom element, it is recommended to use all lowercase letters. Also, include a dash, as this helps distinguish between regular and custom elements.

We'll discuss using the