Pen Settings

HTML

CSS

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

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

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.

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

              
                <h1>HTML Meter</h1>
<p>Demonstration of a <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meter">HTML Meter</a> element. There's a great write-up about styling <code>&lt;Meter&gt;</code> on <a href="https://css-tricks.com/html5-meter-element/">CSS Tricks</a>.</p>

<p><label for="fuel">Password quality</label>
  <input type="password" id="password" size="50"/> <meter id="quality"
       min="0" max="100"
       low="30" high="60" optimum="80"
       value="0">
    at 50/100
</meter> <meter id="qualitah" class="stylish"
       min="0" max="100"
       low="30" high="60" optimum="80"
       value="0">
    at 50/100
</meter>
</p>
              
            
!

CSS

              
                // Common bits
body {
  padding: 1rem;
  font-size: 16px;
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
}

a {
  color: #039;
  
  &:hover,
  &:active,
  &:focus {
    color: #06c;
  }
}

label {
  display: block;
}

// Uncommon bits

// set mixins for things implemented in different browsers in different places
@mixin bar-background() {
  background: #eee;
  box-shadow: 0 0.125em 0.1875em rgba(0, 0, 0, 0.3) inset;
  border-radius: 0.1875em;
}

.stylish {
  // Remove default browser styles
  appearance: none;
  
  // custom appearance
  width: 10rem;
  height: 1.5rem;
  
  // Set bar background for FF
  // Webkit gets handled later
  @include bar-background;
  
  // webkit bar
  &::-webkit-meter-bar {
    @include bar-background;
  }

  // Match border radius to background
  &::-webkit-meter-optimum-value,
  &::-webkit-meter-suboptimum-value,
  &::-webkit-meter-even-less-good-value,
  &::-moz-meter-bar {
    border-radius: 0.1875em;
  }
  
  // set state colours
  &::-webkit-meter-optimum-value,
  &:-moz-meter-optimum::-moz-meter-bar{
    background: #0cc;
  }

  &::-webkit-meter-suboptimum-value,
  &:-moz-meter-sub-optimum::-moz-meter-bar {
    background: #099;
  }

  &::-webkit-meter-even-less-good-value,
  &:-moz-meter-sub-sub-optimum::-moz-meter-bar {
    background: #066;
  }
}
              
            
!

JS

              
                document.getElementById("password").addEventListener("keypress", (event) => {
  const value = event.target.value.length;
  setTargetValue("quality", value);
  setTargetValue("qualitah", value);
})

const setTargetValue = (id, value) => {
    const quality = document.getElementById(id);
  quality.value = value;
}
              
            
!
999px

Console