Pen Settings



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


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


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.


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.


  <h2><code>window.getComputedStyle()</code> returns width and height values even if not defined in the CSS</h2>
  <div class="parent">
    <p>Parent element</p>
    <div class="child">
      <p>Child element</p>
  <p><strong>Resize the parent element</strong>. The width of both elements will be printed on the page on each resize. Neither the parent or child element has a width or height defined in the CSS, but <code>window.getComputedStyle()</code> will still return the actual width or height of the element.</p>



                * {
  box-sizing: border-box;

body {
  padding: 0 20px;
  line-height: 1.4;
  font-size: 1.3em;
  font-family: Helvetica, Arial, sans-serif;

main {
  max-width: 700px;
  margin: 0 auto;

code, output {
  color: firebrick;
  font-family: Consolas, monospace;

.parent {
  overflow: auto;
  border: solid 1px #ccc;
  resize: both;
  padding: 10px;

.child {
  border: solid 1px pink;


                let parent = document.querySelector('.parent'),
    child = document.querySelector('.child'),
    op = document.querySelector('output');

parent.addEventListener('mouseup', function () {
  op.innerHTML = `Parent width is: ${window.getComputedStyle(parent).width}<br><br>
                  Child width is: ${window.getComputedStyle(child).width}`;
}, false);