© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2021
J. KrauseDeveloping Web Components with TypeScripthttps://doi.org/10.1007/978-1-4842-6840-7_7

7. Components and Styles

Jörg Krause1  
(1)
Berlin, Berlin, Germany
 

Due to the fact that the DOM might be isolated, the styles are isolated too. The advantage is primarily the ability to use styles without knowing and disturbing any globally assigned styles. The disadvantage might be the reduced usability of global styles.

Style Behavior

A Shadow DOM may include both <style> and <link rel="stylesheet" href="..."> tags. In the latter case, stylesheets are HTTP-cached, so they are not redownloaded for multiple components that use the same template.

As a general rule, local ...

Get Developing Web Components with TypeScript: Native Web Development Using Thin Libraries 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.