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

              
                <input type="checkbox" id="azerty" /><label for="azerty"> use azerty keyboard layout?</label>
<form>
  <h1>Enter your name</h1>
  <input class="Backspace" type="radio" name="L1" checked />
  <input class="Shift" name="L1-shift" type="checkbox" />
  <p class="Keyboard" style="--index: L1;">
    <input class="Key" type="radio" name="L1" style="--letter: a;" />
    <input class="Key" type="radio" name="L1" style="--letter: b;" />
    <input class="Key" type="radio" name="L1" style="--letter: c;" />
    <input class="Key" type="radio" name="L1" style="--letter: d;" />
    <input class="Key" type="radio" name="L1" style="--letter: e;" />
    <input class="Key" type="radio" name="L1" style="--letter: f;" />
    <input class="Key" type="radio" name="L1" style="--letter: g;" />
    <input class="Key" type="radio" name="L1" style="--letter: h;" />
    <input class="Key" type="radio" name="L1" style="--letter: i;" />
    <input class="Key" type="radio" name="L1" style="--letter: j;" />
    <input class="Key" type="radio" name="L1" style="--letter: k;" />
    <input class="Key" type="radio" name="L1" style="--letter: l;" />
    <input class="Key" type="radio" name="L1" style="--letter: m;" />
    <input class="Key" type="radio" name="L1" style="--letter: n;" />
    <input class="Key" type="radio" name="L1" style="--letter: o;" />
    <input class="Key" type="radio" name="L1" style="--letter: p;" />
    <input class="Key" type="radio" name="L1" style="--letter: q;" />
    <input class="Key" type="radio" name="L1" style="--letter: r;" />
    <input class="Key" type="radio" name="L1" style="--letter: s;" />
    <input class="Key" type="radio" name="L1" style="--letter: t;" />
    <input class="Key" type="radio" name="L1" style="--letter: u;" />
    <input class="Key" type="radio" name="L1" style="--letter: v;" />
    <input class="Key" type="radio" name="L1" style="--letter: w;" />
    <input class="Key" type="radio" name="L1" style="--letter: x;" />
    <input class="Key" type="radio" name="L1" style="--letter: y;" />
    <input class="Key" type="radio" name="L1" style="--letter: z;" />
  </p>

  <input class="Backspace" type="radio" name="L2" checked />
  <input class="Shift" name="L2-shift" type="checkbox" />
  <p class="Keyboard" style="--index: L2;">
    <input class="Key" type="radio" name="L2" style="--letter: a;" />
    <input class="Key" type="radio" name="L2" style="--letter: b;" />
    <input class="Key" type="radio" name="L2" style="--letter: c;" />
    <input class="Key" type="radio" name="L2" style="--letter: d;" />
    <input class="Key" type="radio" name="L2" style="--letter: e;" />
    <input class="Key" type="radio" name="L2" style="--letter: f;" />
    <input class="Key" type="radio" name="L2" style="--letter: g;" />
    <input class="Key" type="radio" name="L2" style="--letter: h;" />
    <input class="Key" type="radio" name="L2" style="--letter: i;" />
    <input class="Key" type="radio" name="L2" style="--letter: j;" />
    <input class="Key" type="radio" name="L2" style="--letter: k;" />
    <input class="Key" type="radio" name="L2" style="--letter: l;" />
    <input class="Key" type="radio" name="L2" style="--letter: m;" />
    <input class="Key" type="radio" name="L2" style="--letter: n;" />
    <input class="Key" type="radio" name="L2" style="--letter: o;" />
    <input class="Key" type="radio" name="L2" style="--letter: p;" />
    <input class="Key" type="radio" name="L2" style="--letter: q;" />
    <input class="Key" type="radio" name="L2" style="--letter: r;" />
    <input class="Key" type="radio" name="L2" style="--letter: s;" />
    <input class="Key" type="radio" name="L2" style="--letter: t;" />
    <input class="Key" type="radio" name="L2" style="--letter: u;" />
    <input class="Key" type="radio" name="L2" style="--letter: v;" />
    <input class="Key" type="radio" name="L2" style="--letter: w;" />
    <input class="Key" type="radio" name="L2" style="--letter: x;" />
    <input class="Key" type="radio" name="L2" style="--letter: y;" />
    <input class="Key" type="radio" name="L2" style="--letter: z;" />
  </p>

  <input class="Backspace" type="radio" name="L3" checked />
  <input class="Shift" name="L3-shift" type="checkbox" />
  <p class="Keyboard" style="--index: L3;">
    <input class="Key" type="radio" name="L3" style="--letter: a;" />
    <input class="Key" type="radio" name="L3" style="--letter: b;" />
    <input class="Key" type="radio" name="L3" style="--letter: c;" />
    <input class="Key" type="radio" name="L3" style="--letter: d;" />
    <input class="Key" type="radio" name="L3" style="--letter: e;" />
    <input class="Key" type="radio" name="L3" style="--letter: f;" />
    <input class="Key" type="radio" name="L3" style="--letter: g;" />
    <input class="Key" type="radio" name="L3" style="--letter: h;" />
    <input class="Key" type="radio" name="L3" style="--letter: i;" />
    <input class="Key" type="radio" name="L3" style="--letter: j;" />
    <input class="Key" type="radio" name="L3" style="--letter: k;" />
    <input class="Key" type="radio" name="L3" style="--letter: l;" />
    <input class="Key" type="radio" name="L3" style="--letter: m;" />
    <input class="Key" type="radio" name="L3" style="--letter: n;" />
    <input class="Key" type="radio" name="L3" style="--letter: o;" />
    <input class="Key" type="radio" name="L3" style="--letter: p;" />
    <input class="Key" type="radio" name="L3" style="--letter: q;" />
    <input class="Key" type="radio" name="L3" style="--letter: r;" />
    <input class="Key" type="radio" name="L3" style="--letter: s;" />
    <input class="Key" type="radio" name="L3" style="--letter: t;" />
    <input class="Key" type="radio" name="L3" style="--letter: u;" />
    <input class="Key" type="radio" name="L3" style="--letter: v;" />
    <input class="Key" type="radio" name="L3" style="--letter: w;" />
    <input class="Key" type="radio" name="L3" style="--letter: x;" />
    <input class="Key" type="radio" name="L3" style="--letter: y;" />
    <input class="Key" type="radio" name="L3" style="--letter: z;" />
  </p>


  <input class="Backspace" type="radio" name="L4" checked />
  <input class="Shift" name="L4-shift" type="checkbox" />
  <p class="Keyboard" style="--index: L4;">
    <input class="Key" type="radio" name="L4" style="--letter: a;" />
    <input class="Key" type="radio" name="L4" style="--letter: b;" />
    <input class="Key" type="radio" name="L4" style="--letter: c;" />
    <input class="Key" type="radio" name="L4" style="--letter: d;" />
    <input class="Key" type="radio" name="L4" style="--letter: e;" />
    <input class="Key" type="radio" name="L4" style="--letter: f;" />
    <input class="Key" type="radio" name="L4" style="--letter: g;" />
    <input class="Key" type="radio" name="L4" style="--letter: h;" />
    <input class="Key" type="radio" name="L4" style="--letter: i;" />
    <input class="Key" type="radio" name="L4" style="--letter: j;" />
    <input class="Key" type="radio" name="L4" style="--letter: k;" />
    <input class="Key" type="radio" name="L4" style="--letter: l;" />
    <input class="Key" type="radio" name="L4" style="--letter: m;" />
    <input class="Key" type="radio" name="L4" style="--letter: n;" />
    <input class="Key" type="radio" name="L4" style="--letter: o;" />
    <input class="Key" type="radio" name="L4" style="--letter: p;" />
    <input class="Key" type="radio" name="L4" style="--letter: q;" />
    <input class="Key" type="radio" name="L4" style="--letter: r;" />
    <input class="Key" type="radio" name="L4" style="--letter: s;" />
    <input class="Key" type="radio" name="L4" style="--letter: t;" />
    <input class="Key" type="radio" name="L4" style="--letter: u;" />
    <input class="Key" type="radio" name="L4" style="--letter: v;" />
    <input class="Key" type="radio" name="L4" style="--letter: w;" />
    <input class="Key" type="radio" name="L4" style="--letter: x;" />
    <input class="Key" type="radio" name="L4" style="--letter: y;" />
    <input class="Key" type="radio" name="L4" style="--letter: z;" />
  </p>


  <input class="Backspace" type="radio" name="L5" checked />
  <input class="Shift" name="L5-shift" type="checkbox" />
  <p class="Keyboard" style="--index: L5;">
    <input class="Key" type="radio" name="L5" style="--letter: a;" />
    <input class="Key" type="radio" name="L5" style="--letter: b;" />
    <input class="Key" type="radio" name="L5" style="--letter: c;" />
    <input class="Key" type="radio" name="L5" style="--letter: d;" />
    <input class="Key" type="radio" name="L5" style="--letter: e;" />
    <input class="Key" type="radio" name="L5" style="--letter: f;" />
    <input class="Key" type="radio" name="L5" style="--letter: g;" />
    <input class="Key" type="radio" name="L5" style="--letter: h;" />
    <input class="Key" type="radio" name="L5" style="--letter: i;" />
    <input class="Key" type="radio" name="L5" style="--letter: j;" />
    <input class="Key" type="radio" name="L5" style="--letter: k;" />
    <input class="Key" type="radio" name="L5" style="--letter: l;" />
    <input class="Key" type="radio" name="L5" style="--letter: m;" />
    <input class="Key" type="radio" name="L5" style="--letter: n;" />
    <input class="Key" type="radio" name="L5" style="--letter: o;" />
    <input class="Key" type="radio" name="L5" style="--letter: p;" />
    <input class="Key" type="radio" name="L5" style="--letter: q;" />
    <input class="Key" type="radio" name="L5" style="--letter: r;" />
    <input class="Key" type="radio" name="L5" style="--letter: s;" />
    <input class="Key" type="radio" name="L5" style="--letter: t;" />
    <input class="Key" type="radio" name="L5" style="--letter: u;" />
    <input class="Key" type="radio" name="L5" style="--letter: v;" />
    <input class="Key" type="radio" name="L5" style="--letter: w;" />
    <input class="Key" type="radio" name="L5" style="--letter: x;" />
    <input class="Key" type="radio" name="L5" style="--letter: y;" />
    <input class="Key" type="radio" name="L5" style="--letter: z;" />
  </p>


  <input class="Backspace" type="radio" name="L6" checked />
  <input class="Shift" name="L6-shift" type="checkbox" />
  <p class="Keyboard" style="--index: L6;">
    <input class="Key" type="radio" name="L6" style="--letter: a;" />
    <input class="Key" type="radio" name="L6" style="--letter: b;" />
    <input class="Key" type="radio" name="L6" style="--letter: c;" />
    <input class="Key" type="radio" name="L6" style="--letter: d;" />
    <input class="Key" type="radio" name="L6" style="--letter: e;" />
    <input class="Key" type="radio" name="L6" style="--letter: f;" />
    <input class="Key" type="radio" name="L6" style="--letter: g;" />
    <input class="Key" type="radio" name="L6" style="--letter: h;" />
    <input class="Key" type="radio" name="L6" style="--letter: i;" />
    <input class="Key" type="radio" name="L6" style="--letter: j;" />
    <input class="Key" type="radio" name="L6" style="--letter: k;" />
    <input class="Key" type="radio" name="L6" style="--letter: l;" />
    <input class="Key" type="radio" name="L6" style="--letter: m;" />
    <input class="Key" type="radio" name="L6" style="--letter: n;" />
    <input class="Key" type="radio" name="L6" style="--letter: o;" />
    <input class="Key" type="radio" name="L6" style="--letter: p;" />
    <input class="Key" type="radio" name="L6" style="--letter: q;" />
    <input class="Key" type="radio" name="L6" style="--letter: r;" />
    <input class="Key" type="radio" name="L6" style="--letter: s;" />
    <input class="Key" type="radio" name="L6" style="--letter: t;" />
    <input class="Key" type="radio" name="L6" style="--letter: u;" />
    <input class="Key" type="radio" name="L6" style="--letter: v;" />
    <input class="Key" type="radio" name="L6" style="--letter: w;" />
    <input class="Key" type="radio" name="L6" style="--letter: x;" />
    <input class="Key" type="radio" name="L6" style="--letter: y;" />
    <input class="Key" type="radio" name="L6" style="--letter: z;" />
  </p>


  <input class="Backspace" type="radio" name="L7" checked />
  <input class="Shift" name="L7-shift" type="checkbox" />
  <p class="Keyboard" style="--index: L7;">
    <input class="Key" type="radio" name="L7" style="--letter: a;" />
    <input class="Key" type="radio" name="L7" style="--letter: b;" />
    <input class="Key" type="radio" name="L7" style="--letter: c;" />
    <input class="Key" type="radio" name="L7" style="--letter: d;" />
    <input class="Key" type="radio" name="L7" style="--letter: e;" />
    <input class="Key" type="radio" name="L7" style="--letter: f;" />
    <input class="Key" type="radio" name="L7" style="--letter: g;" />
    <input class="Key" type="radio" name="L7" style="--letter: h;" />
    <input class="Key" type="radio" name="L7" style="--letter: i;" />
    <input class="Key" type="radio" name="L7" style="--letter: j;" />
    <input class="Key" type="radio" name="L7" style="--letter: k;" />
    <input class="Key" type="radio" name="L7" style="--letter: l;" />
    <input class="Key" type="radio" name="L7" style="--letter: m;" />
    <input class="Key" type="radio" name="L7" style="--letter: n;" />
    <input class="Key" type="radio" name="L7" style="--letter: o;" />
    <input class="Key" type="radio" name="L7" style="--letter: p;" />
    <input class="Key" type="radio" name="L7" style="--letter: q;" />
    <input class="Key" type="radio" name="L7" style="--letter: r;" />
    <input class="Key" type="radio" name="L7" style="--letter: s;" />
    <input class="Key" type="radio" name="L7" style="--letter: t;" />
    <input class="Key" type="radio" name="L7" style="--letter: u;" />
    <input class="Key" type="radio" name="L7" style="--letter: v;" />
    <input class="Key" type="radio" name="L7" style="--letter: w;" />
    <input class="Key" type="radio" name="L7" style="--letter: x;" />
    <input class="Key" type="radio" name="L7" style="--letter: y;" />
    <input class="Key" type="radio" name="L7" style="--letter: z;" />
  </p>
  

  <input class="Backspace" type="radio" name="L8" checked />
  <input class="Shift" name="L8-shift" type="checkbox" />
  <p class="Keyboard" style="--index: L8;">
    <input class="Key" type="radio" name="L8" style="--letter: a;" />
    <input class="Key" type="radio" name="L8" style="--letter: b;" />
    <input class="Key" type="radio" name="L8" style="--letter: c;" />
    <input class="Key" type="radio" name="L8" style="--letter: d;" />
    <input class="Key" type="radio" name="L8" style="--letter: e;" />
    <input class="Key" type="radio" name="L8" style="--letter: f;" />
    <input class="Key" type="radio" name="L8" style="--letter: g;" />
    <input class="Key" type="radio" name="L8" style="--letter: h;" />
    <input class="Key" type="radio" name="L8" style="--letter: i;" />
    <input class="Key" type="radio" name="L8" style="--letter: j;" />
    <input class="Key" type="radio" name="L8" style="--letter: k;" />
    <input class="Key" type="radio" name="L8" style="--letter: l;" />
    <input class="Key" type="radio" name="L8" style="--letter: m;" />
    <input class="Key" type="radio" name="L8" style="--letter: n;" />
    <input class="Key" type="radio" name="L8" style="--letter: o;" />
    <input class="Key" type="radio" name="L8" style="--letter: p;" />
    <input class="Key" type="radio" name="L8" style="--letter: q;" />
    <input class="Key" type="radio" name="L8" style="--letter: r;" />
    <input class="Key" type="radio" name="L8" style="--letter: s;" />
    <input class="Key" type="radio" name="L8" style="--letter: t;" />
    <input class="Key" type="radio" name="L8" style="--letter: u;" />
    <input class="Key" type="radio" name="L8" style="--letter: v;" />
    <input class="Key" type="radio" name="L8" style="--letter: w;" />
    <input class="Key" type="radio" name="L8" style="--letter: x;" />
    <input class="Key" type="radio" name="L8" style="--letter: y;" />
    <input class="Key" type="radio" name="L8" style="--letter: z;" />
  </p>
  
  <output class="Output"></output>
  <button class="Reset" type="reset">Reset</button>
</form>

<footer>
  This is an example from the <a href="https://www.kizu.ru/counters/">“Not your usual CSS counters”</a> talk at dotCSS.
</footer>
              
            
!

CSS

              
                form {
  display: grid;
  max-width: 36em;
  
  font: 1em sans-serif;
  grid-template:
    "header symbols-left"
    "input reset"
    "input backspace"
    "input shift"
    "output output";
  grid-gap: 4px;
  counter-reset: symbols-left 8 L1 L2 L3 L4 L5 L6 L7 L8;
  place-items: center;
}

form::after {
  place-self: center;
  grid-area: symbols-left;
  content: "Symbols left: " counter(symbols-left)
}

h1 {
  grid-area: header;
}

.Keyboard {
  grid-area: input;
  display: grid;
  grid-gap: 4px;
  /* In order to have a shift we need to duplicate the slots */
  grid-template-areas:
    "q q w w e e r r t t y y u u i i o o p p ."
    ". a a s s d d f f g g h h j j k k l l . ."
    ". . z z x x c c v v b b n n m m . . . . .";
  
  margin: 0;
  font: 1em Monaco, monospace;
  --case: lower-alpha;
}

#azerty:checked + * + form > .Keyboard {
  grid-template-areas:
    "a a z z e e r r t t y y u u i i o o p p ."
    ". q q s s d d f f g g h h j j k k l l m m"
    ". . w w x x c c v v b b n n . . . . . . .";
}

.Key,
.Reset,
.Backspace,
.Shift {
  border: 1px solid;
  padding: 0.5em;
  margin: 0;
  text-align: center;
  font: inherit;
  appearance: none;
  
  background: #FFF;
  color: #000;
  border-radius: 3px;
}

.Key {
  grid-area: var(--letter);
  counter-reset: label var(--value);
  min-width: 2.4em;
}

/* If only we had a way to do `var(var(--variable-name))`… */
/* Or maps, or any other more complex thing */
.Key[style*="--letter: a;"] { --value: 1; }
.Key[style*="--letter: b;"] { --value: 2; }
.Key[style*="--letter: c;"] { --value: 3; }
.Key[style*="--letter: d;"] { --value: 4; }
.Key[style*="--letter: e;"] { --value: 5; }
.Key[style*="--letter: f;"] { --value: 6; }
.Key[style*="--letter: g;"] { --value: 7; }
.Key[style*="--letter: h;"] { --value: 8; }
.Key[style*="--letter: i;"] { --value: 9; }
.Key[style*="--letter: j;"] { --value: 10; }
.Key[style*="--letter: k;"] { --value: 11; }
.Key[style*="--letter: l;"] { --value: 12; }
.Key[style*="--letter: m;"] { --value: 13; }
.Key[style*="--letter: n;"] { --value: 14; }
.Key[style*="--letter: o;"] { --value: 15; }
.Key[style*="--letter: p;"] { --value: 16; }
.Key[style*="--letter: q;"] { --value: 17; }
.Key[style*="--letter: r;"] { --value: 18; }
.Key[style*="--letter: s;"] { --value: 19; }
.Key[style*="--letter: t;"] { --value: 20; }
.Key[style*="--letter: u;"] { --value: 21; }
.Key[style*="--letter: v;"] { --value: 22; }
.Key[style*="--letter: w;"] { --value: 23; }
.Key[style*="--letter: x;"] { --value: 24; }
.Key[style*="--letter: y;"] { --value: 25; }
.Key[style*="--letter: z;"] { --value: 26; }

.Key:checked {
  counter-increment: var(--index) var(--value);
}

.Key::before {
  content: counter(label, var(--case));
}

.Reset {
  grid-area: reset;
  place-self: center;
  visibility: hidden;
}

.Shift:checked + .Keyboard {
  --case: upper-alpha;
}

.Shift {
  grid-area: shift;
  place-self: center;
}

.Shift:checked {
  color: #FFF;
  background: #000;
}

.Shift::before {
  content: "Shift"
}

.Backspace {
  grid-area: backspace;
  place-self: center;
}

.Backspace:not(:checked) {
  counter-increment: symbols-left -1;
}

.Backspace::before {
  content: "backspace";
}

.Backspace[name=L1]:not(:checked) ~ .Output { --L1: var(--L1-case, lower-alpha); }
.Backspace[name=L2]:not(:checked) ~ .Output { --L2: var(--L2-case, lower-alpha); }
.Backspace[name=L3]:not(:checked) ~ .Output { --L3: var(--L3-case, lower-alpha); }
.Backspace[name=L4]:not(:checked) ~ .Output { --L4: var(--L4-case, lower-alpha); }
.Backspace[name=L5]:not(:checked) ~ .Output { --L5: var(--L5-case, lower-alpha); }
.Backspace[name=L6]:not(:checked) ~ .Output { --L6: var(--L6-case, lower-alpha); }
.Backspace[name=L7]:not(:checked) ~ .Output { --L7: var(--L7-case, lower-alpha); }
.Backspace[name=L8]:not(:checked) ~ .Output { --L8: var(--L8-case, lower-alpha); }

.Shift[name=L1-shift]:checked ~ .Output { --L1-case: upper-alpha; }
.Shift[name=L2-shift]:checked ~ .Output { --L2-case: upper-alpha; }
.Shift[name=L3-shift]:checked ~ .Output { --L3-case: upper-alpha; }
.Shift[name=L4-shift]:checked ~ .Output { --L4-case: upper-alpha; }
.Shift[name=L5-shift]:checked ~ .Output { --L5-case: upper-alpha; }
.Shift[name=L6-shift]:checked ~ .Output { --L6-case: upper-alpha; }
.Shift[name=L7-shift]:checked ~ .Output { --L7-case: upper-alpha; }
.Shift[name=L8-shift]:checked ~ .Output { --L8-case: upper-alpha; }

/* In theory, some of this stuff can be replaced by flex overflower */
.Backspace:checked,
.Backspace:not(:checked) + .Shift,
.Backspace:not(:checked) + .Shift + .Keyboard,
.Backspace:checked + .Shift + .Keyboard ~ .Keyboard,
.Backspace:checked + .Shift + .Keyboard ~ .Shift {
  visibility: hidden;
}

.Output {
  padding: 1em;
  visibility: hidden;
}

.Output::after {
  content:
    "Hello, "
    counter(L1, var(--L1, none))
    counter(L2, var(--L2, none))
    counter(L3, var(--L3, none))
    counter(L4, var(--L4, none))
    counter(L5, var(--L5, none))
    counter(L6, var(--L6, none))
    counter(L7, var(--L7, none))
    counter(L8, var(--L8, none))
    "!";
}

.Backspace:not(:checked) ~ .Reset,
.Backspace:not(:checked) ~ .Output {
  visibility: inherit;
}

html {
  font: 1.25em Helvetica Neue, sans-serif;
  background: #010101;
  color: #FFF;
}

a[href] {
  color: #FFF;
}

body {
  padding: 3em;
}


              
            
!

JS

              
                          
              
            
!
999px

Console