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.


    <h1>Select/Highlight the text below:</h1>
    <p class="red">This element has a <span>red</span> selection color.</p>
    <p class="yellow">This element has a <span>yellow</span> selection color.</p>   
    <p class="green">This element has a <span>green</span> selection color.</p>
    <p class="blue">This element has a <span>blue</span> selection color.</p>    
    <p class="purple">This element has a <span>purple</span> selection color.</p>   


                @import url(;

body {
  font-family: 'Exo 2', sans-serif; 
  background: #f9f9f0;
  min-height: 100vh;
  padding: 2.2em;

  font-size: 3rem;
  margin-bottom: 1em;

p {
  /*declare and define variables, scoped to the P elements and descendants*/
  --bg: initial;
  --color: initial;
  font-size: 1.6rem;
  margin-bottom: 2.2rem;
  color: #111;

p span,
p span::selection {
  /*sets selection properties and use variables as the value*/
  background-color: var(--bg);
  color: var(--color);

p span,
p span::-moz-selection {
  /*firefox prefixed version*/
  background-color: var(--bg);
  color: var(--color);

/*only change the values on the class modifier, so keeps it way, waaaaay drier*/
.red {
  --bg: red;

.yellow {
  --bg: yellow;
  --color: #111;

.green {
  --bg: green;

.blue {
  --bg: blue;

.purple {
  --bg: purple;


This is a fork on George W. Park's previous pen, so credit where it's due :)

I build on his great bit of code but use CSS Custom Properties (variables) to keep the code way drier.

Downside is, as always, loosing support for IE.