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

              
                <p><a href="http://www.w3.org/TR/CSS2/syndata.html#value-def-identifier">The CSS Spec</a> says you can't start a class name with a number. HOWEVER you can start it with a backslash-escaped identifier. So ".2 {}" is invalid, but ".\32 {}" - the character sequence for '2' is valid. Thanks to some solid coincidences the codepoints for numbers begin at \30, so \30 is 0, \31 is 1, \32 is 2 etc. So if you want to start your class name with a number prefix it with \3 and you're golden assuming you want a single number as the initial value.</p>

<p>In case you need to start a class name with multiple numbers characters - such as if you want a numerator of "15" - then CSS needs to be able to tell the difference between "that character is an literal character" and "that character is part of an escape sequence". There are a few ways to do this. The following examples all represent the classname "15/24": you can escape every number (e.g. ".\31\35\/24"), you can add a space after the end of an escape sequence (e.g. ".\31 5\/24"), or you can have exactly six hex characters in the escape code (e.g. ".\0000315\/24"). Using all escape sequences feels cleanest to me when we're talking about just numbers.</p>

<p>In addition to that, you can also have all kinds of other characters <a href="https://mathiasbynens.be/notes/css-escapes">as long as you escape them</a>. In this instance we're using / to show numeric fractions and <a href="https://csswizardry.com/2015/08/bemit-taking-the-bem-naming-convention-a-step-further/#responsive-suffixes">@ to denote changes at a given breakpoint</a>.</p>

<p>The following is totally valid HTML and CSS:</p>

<hr>

<div class="grid">
  <div class="grid__item 1/1 1/3@large"><p><code>1/1 1/3@large</code><br>Full width as a baseline, one third at large sizes</p></div>
  <div class="grid__item 1/2 1/3@large"><p><code>1/2 1/3@large</code><br>One half width as a baseline, one third at large sizes</p></div>
  <div class="grid__item 1/2 1/3@large"><p><code>1/2 1/3@large</code><br>One half width as a baseline, one third at large sizes</p></div>
</div>

<div class="grid">
  <div class="grid__item 11/24"><p><code>11/24 </code><br>Slightly under half width as a baseline</p></div>
  <div class="grid__item 13/24"><p><code>11/24</code><br>Slightly over half width as a baseline, is bold and italic to demonstrate other ways of targeting numerators greater than or equal to 10</p></div>
</div>
              
            
!

CSS

              
                /* Base Widths */
.\31\/1 { width: 100%; }

.\31\/2 { width: 50%; }

.\31\/3 { width: 33.33333%; }
.\32\/3 { width: 66.66666%; }

/* Numbers bigger than 10 can be represented by escaping every non-hex character */
.\31\31\/24 { width: 45.83333% } /* 11/24 */
.\31\33\/24 { width: 54.16667% } /* 13/24 */

/* There are other ways to make it explicit when an escape sequence ends, both of these target "13/24" */
.\31 3\/24 { font-weight: bold; } /* a space deliniates the end of an escape sequence */
.\0000313\/24 { font-style: italic; } /* using 6 hex chars for the escape sequence */


/* Use the @ suffix to identify particular breakpoints */
@media (min-width: 600px) {
  .\31\/1\@large { width: 100%; }

  .\31\/2\@large { width: 50%; }

  .\31\/3\@large { width: 33.33333%; }
  .\32\/3\@large { width: 33.33333%; }
}



/* The simplest of grids systems */
.grid {
  margin-left: -8px;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
  list-style: none;
  letter-spacing: -0.31em;
}

.opera:-o-prefocus,
.grid {
  word-spacing: -0.43em;
}


.grid__item {
  display: inline-block;
  box-sizing: border-box;
  padding-left: 8px;
  vertical-align: top;
  letter-spacing:normal;
  word-spacing:normal;
}

/* A splash of color */
.grid__item:nth-child(1) { color: red; }
.grid__item:nth-child(2) { color: green; }
.grid__item:nth-child(3) { color: blue; }
              
            
!

JS

              
                console.log(document.querySelectorAll('.\\31\\/1'));
              
            
!
999px

Console