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 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.


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.


                <h2>Working with the <code>style</code> object of an individual style rule in an external Stylesheet</h2>

<p>Below are the outputs from using various methods of the <code>CSStyleDeclaration</code> API, exposed on a single style rule in an external stylesheet. See the JS panel for details.</p>

<p class="output"></p>

<p>Try adjusting some of the styles in the CSS panel and the changes will be reflected in the output above.</p>



                * {
  box-sizing: border-box;

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

main {
  width: 1024px;
  margin: 0 auto !important;

.component {
  float: right;
  border-left: solid 1px #444;
  margin-left: 20px;

@media (max-width: 800px) {
  body {
    line-height: 1.2;

  .component {
    float: none;
    margin: 0;

a:hover {
  color: lightgreen;

@keyframes exampleAnimation {
  from {
    color: blue;

  20% {
    color: orange;

  to {
    color: green;

code {
  color: firebrick;


                // Grab the "body" and "main" style rules
let myBodyRule = document.styleSheets[0].cssRules[1].style,
    myMainRule = document.styleSheets[0].cssRules[2].style,
    p = document.querySelector('.output');

// Set the bg color
myBodyRule.setProperty('background-color', 'peachpuff');

// Get the font size
p.innerHTML += `font-size is: <code> ${myBodyRule.getPropertyValue('font-size')} </code><br>`;

// Get the 5th item in the style rule
p.innerHTML += `5th item in the style rule is: <code>${myBodyRule.item(5)}</code><br>`;

// Log the current length of the body style rule (8)
p.innerHTML += `Length of the style rule: <code>${myBodyRule.length}</code><br>`;

// Remove the line height

// log the length again (7)
p.innerHTML += `Length of the style rule after removing line-height: <code>${myBodyRule.length}</code><br>`;

// Check the priority of font-family (empty string)
p.innerHTML += `Priority of font-family is: <code>${myBodyRule.getPropertyPriority('font-family')}</code><br>`;

// Check property priority of margin in the "main" style rule
p.innerHTML += `Priority of margin on main element is: <code>${myMainRule.getPropertyPriority('margin')}</code>`;