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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

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


                <div class="intro">
  This was put together as a result of me having a great time learning from lesson 20 of <a href="">#javascript30</a> by <a href="">@wesbos</a>.
<div class="controls">
    <input type="radio" name="language" value="da-DK" checked>
    <label for="male">Dansk</label>
    <input type="radio" name="language" value="es-MX">
    <label for="female">Español (MX)</label>
    <input type="radio" name="language" value="en-US">
    <label for="other">English (US)</label>
  <div class="controls__text">
    <p><span class="say">Sig</span> <span class="trigger">skift farve</span> <span class="explain">for at skifte baggrundsfarve</span></p>
<div class="words" contenteditable>


                :root {
  --bg: #ffc600;

html {
  font-size: 10px;

body {
  background: var(--bg);
  font-family: 'helvetica neue';
  font-weight: 200;
  font-size: 20px;

.intro {
  font-weight: bold;
.controls {
  max-width: 500px;
  margin: 50px auto;

.controls__text {
  margin-top: 20px;

.trigger {
  font-style: italic;

.words {
  max-width: 500px;
  margin: 50px auto;
  background: white;
  border-radius: 5px;
  box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.1);
  padding: 1rem 2rem 1rem 5rem;
  background: -webkit-gradient(
      0 0,
      0 100%,
      color-stop(4%, #fff)
  background-size: 100% 3rem;
  position: relative;
  line-height: 3rem;

p {
  margin: 0 0 3rem;

.words:before {
  content: '';
  position: absolute;
  width: 4px;
  top: 0;
  left: 30px;
  bottom: 0;
  border: 1px solid;
  border-color: transparent #efe4e4;



                window.SpeechRecognition =
  window.SpeechRecognition || window.webkitSpeechRecognition;

const recognition = new SpeechRecognition();
recognition.lang = "da-DK ";
recognition.interimResults = true;

const langStrings = {
  "da-DK": {
    say: "Sig",
    trigger: "skift farve",
    explain: "for at skifte farve"
  "es-MX": {
    say: "Di",
    trigger: "cambia el color",
    explain: "para cambiar el color de fondo"
  "en-US": {
    say: "Say",
    trigger: "change background",
    explain: "to change the background color"

const controls = document.querySelector(".controls");
const say = controls.querySelector(".say");
const trigger = controls.querySelector(".trigger");
const explain = controls.querySelector(".explain");
controls.addEventListener("change", e => {
  if (!"input") || ! {
    // Not what we are listening for, so return.
  // Set the language.
  recognition.lang =;
  // Update the controls text.
  say.textContent = langStrings[].say;
  trigger.textContent = langStrings[].trigger;
  explain.textContent = langStrings[].explain;

let p = document.createElement("p");
const words = document.querySelector(".words");

function changeColor() {
    `hsl(${360 * Math.random()}, ${100 * Math.random()}%, ${90 *

recognition.addEventListener("result", e => {
  const transcript = Array.from(e.results)
  .map(result => result[0])
  .map(result => result.transcript)
  p.textContent = transcript;
  if (e.results[0].isFinal) {
    p = document.createElement("p");

    if (transcript.includes(trigger.textContent)) {

recognition.addEventListener("end", e => {