Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


              <!-- The template used for the custom element -->
<template id="user-comment-template">
  <!-- Styles will be scoped inside the shadow DOM -->
    .container {
      align-items: center;
      display: flex;
      max-width: 100%;
      padding: 0.5rem;
    .avatar-container {
      background: lightgray;
      border-radius: 100%;
      height: 3rem;
      margin-right: 0.5rem;
      overflow: hidden;
      width: 3rem;
    /* Style the image directly - either the slotted one or the default */
    slot[name="avatar"]::slotted(img), slot[name="avatar"] img, {
      max-width: 100%;
    slot[name="username"], slot[name="comment"] {
      display: block;
    slot[name="username"] {
      font-weight: bold;
      margin-bottom: 0.25rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    .comment {
      flex: 1;
      min-width: 0;
    .unknown {
      opacity: 0.5;
  <!-- The contents of the web component -->
  <div class="container">
    <div class="avatar-container">
      <slot name="avatar">
        <!-- Placeholder content when there is no data for the slot -->
        <img alt="" src="" />
    <div class="comment">
      <slot name="username">
        <!-- Placeholder content when there is no data for the slot -->
        <span class="unknown">No name</span>
      <slot name="comment">
        <!-- Placeholder content when there is no data for the slot -->
        <span class="unknown">This user did not leave a comment</span>

<!-- How to use the new user-comment element -->
  <img alt="" slot="avatar" src="" />
  <span slot="username">Matt Crouch</span>
  <div slot="comment">This is an example of a comment a user might leave</div>

<!-- What happens if the developer does not pass values to a slot -->
  <!-- Default values -->


              @import url(",700");

* {
  box-sizing: border-box;

html {
  font-family: Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  font-smooth: always;
  -webkit-font-smoothing: antialiased;
  line-height: 1.25;

body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 auto;
  min-height: 100vh;
  width: 66%;


              // Create a new UserComment element
class UserComment extends HTMLElement {
  constructor() {
    // Create an open shadow DOM that this component can use
    this.attachShadow({ mode: "open" });
  // What to do when the component gets connected
  connectedCallback() {
    // Find the required template
    const template = document.getElementById("user-comment-template");
    // Copy the template content
    const node = document.importNode(template.content, true);
    // Apply it to the shadow DOM

// Tell the browser that the `user-comment` element should use this component class
customElements.define("user-comment", UserComment);