Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML

              
                <user-avatar>
  <img src="https://naildrivin5.com/images/DavidCopelandAvatar-512.jpeg"
       alt="Profile photo of Dave Copeland"
       width="64"
       height="64"
       title="Dave Copeland"
       />
</user-avatar>
<hr>
<button data-add-new>Add New Component</button>
<h2>New Components are added here</h2>
<section>

</section>
              
            
!

CSS

              
                
              
            
!

JS

              
                class UserAvatar extends HTMLElement {
  connectedCallback() {
    // Get the data for the component from exisiting markup
    const $img = this.querySelector("img");
    if (!$img) {
      return;
    }
    const src = $img.getAttribute("src");
    const title = $img.getAttribute("title");
    if (!src) {
      return;
    }
    if (!title) {
      return;
    }

    // Create the markup and event listeners for tooltip...

    // Append it to the DOM
    this.insertAdjacentHTML("beforeend", `<div>tooltip ${title}</div>`);
  }
}
customElements.define("user-avatar", UserAvatar);

document.querySelectorAll("[data-add-new]").forEach((e) => {
  e.addEventListener("click", (event) => {
    event.preventDefault();
    const section = document.querySelector("section");
    section.insertAdjacentHTML(
      "beforebegin",
      `
    <user-avatar>
  <img src="https://naildrivin5.com/images/DavidCopeland-old.jpeg"
       alt="Old Profile photo of Dave Copeland"
       width="64"
       title="Younger Dave Copeland"
       />
</user-avatar>
    `
    );
  });
});

              
            
!
999px

Console