cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

              <div id="cc">
  <span id="cc-button" ><button onclick="toggleSpeechRecognition(event)"><abbr title="Closed Captioning">CC</abbr> Click to caption</button></span>
  <span id="cc-text" style="display: none;" onclick="toggleSpeechRecognition(event)" tabindex="0">Begin speaking. Click to stop.</span>

  <h1>HTML5 Closed Captioning</h1>
    <li>Open this page in Chrome desktop (25+)</li>
    <li>Click button to begin captioning</li>
    <li>Allow use of microphone</li>
    <li>Begin talking. May need to pause occasionaly.</li>
    <li>Click to caption stop</li>

              /* Layout styling */
body {
  height: 100%;
  background: #f0f0f0;

body {
  font-family: 'Ubuntu', sans-serif;
  line-height: 1.5;
  padding: 4em 1em 1em;
  text-align: center;

ol {
    padding-left: 0;

li {
  list-style-position: inside;

/* Caption Styling */
#cc {
  text-align: center;
  width: 80%;  
  left: 10%;
  position: fixed;
  top: 1em;

#cc span {
  display: inline-block;
  width: auto;
  margin: 0 auto;
  background: black;
  color: white;
  font-size: 1.5em;
  padding: 0.5em;
  min-height: 1.5em;
  line-height: 1.5em;

#cc button {
  appearance: none;
  border: 0;
  font-size: 1em;
  background: transparent;
  color: white;

#cc abbr {
  background: white;
  border-radius: 4px;
  color: black;
  font-weight: bold;
  font-family: sans-serif;
  font-size: 0.8em;
  display: inline-block;
  padding: 0 0.25em;
              var cc = document.getElementById('cc-text');
var button = document.getElementById('cc-button');

var recognizing = false;

var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.interimResults = true;
recognition.onstart = function() {
  recognizing = true;

recognition.onerror = function(event) {};
recognition.onend = function() {
  recognizing = false;

recognition.onresult = function(event) {
  for (var i = event.resultIndex; i < event.results.length; ++i) {
    if(event.results[i][0].confidence > 0.4) {
      cc.innerHTML = capitalize(event.results[i][0].transcript);

function capitalize(s) {
  var first_char = /\S/;
 return s.replace(first_char, function(m) { 
    return m.toUpperCase(); 

function toggleSpeechRecognition(event) {
  if(recognizing) {
    cc.style.display = "none";
    button.style.display = "inline-block";
  } else {
    cc.style.display = "inline-block";
    button.style.display = "none";
Loading ..................