css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div class="intro">
  This was put together as a result of me having a great time learning from lesson 20 of <a href="https://javascript30.com">#javascript30</a> by <a href="https://twitter.com/wesbos">@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 (!e.target.matches("input") || !e.target.checked) {
    // Not what we are listening for, so return.
  // Set the language.
  recognition.lang = e.target.value;
  // Update the controls text.
  say.textContent = langStrings[e.target.value].say;
  trigger.textContent = langStrings[e.target.value].trigger;
  explain.textContent = langStrings[e.target.value].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 => {

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................