{"id":335065,"date":"2021-03-08T08:06:03","date_gmt":"2021-03-08T16:06:03","guid":{"rendered":"https:\/\/css-tricks.com\/?p=335065"},"modified":"2022-02-28T07:39:45","modified_gmt":"2022-02-28T15:39:45","slug":"web-components-are-easier-than-you-think","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/web-components-are-easier-than-you-think\/","title":{"rendered":"Web Components Are Easier Than You Think"},"content":{"rendered":"\n

When I\u2019d go to a conference (when we were able to do such things) and see someone do a presentation on web components, I always thought it was pretty nifty (yes, apparently, I\u2019m from 1950), but it always seemed complicated and excessive. A thousand lines of JavaScript to save four lines of HTML. The speaker would inevitably either gloss over the oodles of JavaScript to get it working or they\u2019d go into excruciating detail and my eyes would glaze over as I thought about whether my per diem covered snacks.<\/p>\n\n\n\n

But in a recent reference project<\/a> to make learning HTML easier (by adding zombies and silly jokes, of course), the completist in me decided I had to cover every HTML element in the spec. Beyond those conference presentations, this was my first introduction to the <slot><\/code> and <template><\/code> elements. But as I tried to write something accurate and engaging, I was forced to delve a bit deeper.<\/p>\n\n\n\n

And I\u2019ve learned something in the process: web components are a lot easier than I remember.<\/strong><\/p>\n\n\n\n\n\n\n

Article series<\/h2>\n\n\n