Pen Settings



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


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.


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.


                <select id="lang"></select><select id="voice"></select><br>
<textarea id="src" rows="20" cols="60" spellcheck="false"></textarea><br>
<button id="btnSpeak">Speak</button>





                // CC0

let voices = [];
let speaking = false;
if (window.speechSynthesis) init();

async function init() {
  await initVoices();
  function changeLang() {
    const opt = lang.selectedOptions;
    if (opt.length) {
      setVoices(opt[0].value, voice, btnSpeak);
  lang.addEventListener("change", changeLang);
  btnSpeak.addEventListener("click", () => speak(voice, src, btnSpeak));

// Web Speech API

async function initVoices() {
  if (voices.length) return;
  voices = speechSynthesis.getVoices();
  if (!voices.length) {
    await new Promise((resolve, reject) =>
      speechSynthesis.addEventListener("voiceschanged", resolve)
    voices = speechSynthesis.getVoices();
  let langs = [];
  for (const v of voices) {
    let vl = v.lang.replace(/(?<=^[a-z]+)_/, "-").replace(/_#.+/, ""); // for Android Chrome
    let p = vl.indexOf("-");
    if (p > 0) {
      let l = vl.substring(0, p);
      if (langs.findIndex(x => x == l) < 0) langs.push(l);
  for (const l of langs) {
    addOption(lang, l);

function addOption(select, text) {
  const opt = document.createElement("option");
  opt.text = text;
  return opt;

function setVoices(lang, select, button) {
  select.innerHTML = "";
  let sel;
  const targets = voices.filter((v) => v.lang.startsWith(lang));
  for (const v of targets) {
    let opt = addOption(select,;
    opt.voice = v;
    if ("(Natural)")) sel = opt;
  if (sel) sel.selected = true;
  if (targets.length == 0) {
    addOption(select, "Microsoft Edge Required");
    button.disabled = true;

async function speak(select, textarea, button1, button2) {
  if (speaking) {
  const opt = select.selectedOptions;
  if (!opt.length || !opt[0].voice) return;
  speaking = true;
  let tc = button1.textContent;
  button1.textContent = "Stop";
  if (button2) button2.disabled = true;
  await new Promise((resolve, reject) => {
    const u = new SpeechSynthesisUtterance(textarea.value);
    u.voice = opt[0].voice;
    u.lang = u.voice.lang;
    u.onend = resolve;
    u.addEventListener("boundary", (e) => {
      if ( != "word") return;
      textarea.setSelectionRange(e.charIndex, e.charIndex + e.charLength);
  textarea.setSelectionRange(0, 0);
  speaking = false;
  button1.textContent = tc;
  if (button2) button2.disabled = false;