Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <div class=buttons>
	<button id=play></button> &nbsp;
	<button id=pause></button> &nbsp;
	<button id=stop></button>
</div>
<article> <html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Rabindranath Tagore</title>
</head>
<body>
    <h1>Rabindranath Tagore</h1>
    <p>Rabindranath Tagore (born May 7, 1861, Calcutta [now Kolkata], India—died August 7, 1941, Calcutta) was a Bengali poet, short-story writer, song composer, playwright, essayist, and painter who introduced new prose and verse forms and the use of colloquial language into Bengali literature, thereby freeing it from traditional models based on classical Sanskrit. He was highly influential in introducing Indian culture to the West and vice versa, and he is generally regarded as the outstanding creative artist of early 20th-century India. In 1913 he became the first non-European to receive the Nobel Prize for Literature.</p>
    <p>The son of the religious reformer Debendranath Tagore, he early began to write verses, and, after incomplete studies in England in the late 1870s, he returned to India. There he published several books of poetry in the 1880s and completed <em>Manasi</em> (1890), a collection that marks the maturing of his genius. It contains some of his best-known poems, including many in verse forms new to Bengali, as well as some social and political satire that was critical of his fellow Bengalis.</p>
</body>
</html>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Crimson+Text');
html {
	font-size: 16pt;
	font-family: crimson text;
}

article {
	width: 60%;
	margin: auto;
}

blockquote,
div,
h1 {
	text-align: center;
}

blockquote {
	font-size: 1.2rem;
}

.buttons {
	margin-top: 25px;
}

button {
	background: none;
	border: none;
	cursor: pointer;
	height: 48px;
	outline: none;
	padding: 0;
	width: 48px;
}

#play {
	background-image: url(https://rpsthecoder.github.io/js-speech-synthesis/play.svg);
}

#play.played {
	background-image: url(https://rpsthecoder.github.io/js-speech-synthesis/play1.svg);
}

#pause {
	background-image: url(https://rpsthecoder.github.io/js-speech-synthesis/pause.svg);
}

#pause.paused {
	background-image: url(https://rpsthecoder.github.io/js-speech-synthesis/pause1.svg);
}

#stop {
	background-image: url(https://rpsthecoder.github.io/js-speech-synthesis/stop.svg);
}

#stop.stopped {
	background-image: url(https://rpsthecoder.github.io/js-speech-synthesis/stop1.svg);
}

@media (max-width: 700px) {
	html {
		font-size: 14pt;
	}
	article {
		width: 90%;
	}
}

body {
	margin: 0;
}


/*  demo decor */

#-demo-title {
	position: fixed;
	top: 0;
	width: 100%;
	height: 36px;
	background-color: #D5FFD1;
	color: #0F316C;
	line-height: 36px;
	font-weight: bold;
	font-size: 16pt;
	text-align: center;
}

#-demo-profile {
	float: left;
	height: 100%;
	opacity: .4;
}

#-demo-profile:hover {
	opacity: 1;
}

@media (max-width: 400px) {
	#-demo-title {
		font-size: 12pt;
	}
}
              
            
!

JS

              
                onload = function() {
	if ('speechSynthesis' in window) with(speechSynthesis) {

		var playEle = document.querySelector('#play');
		var pauseEle = document.querySelector('#pause');
		var stopEle = document.querySelector('#stop');
		var flag = false;

		playEle.addEventListener('click', onClickPlay);
		pauseEle.addEventListener('click', onClickPause);
		stopEle.addEventListener('click', onClickStop);

		function onClickPlay() {
			if (!flag) {
				flag = true;
				utterance = new SpeechSynthesisUtterance(document.querySelector('article').textContent);
				utterance.voice = getVoices()[0];
				utterance.onend = function() {
					flag = false;
					playEle.className = pauseEle.className = '';
					stopEle.className = 'stopped';
				};
				playEle.className = 'played';
				stopEle.className = '';
				speak(utterance);
			}
			if (paused) { /* unpause/resume narration */
				playEle.className = 'played';
				pauseEle.className = '';
				resume();
			}
		}

		function onClickPause() {
			if (speaking && !paused) { /* pause narration */
				pauseEle.className = 'paused';
				playEle.className = '';
				pause();
			}
		}

		function onClickStop() {
			if (speaking) { /* stop narration */
				/* for safari */
				stopEle.className = 'stopped';
				playEle.className = pauseEle.className = '';
				flag = false;
				cancel();

			}
		}

	}

	else { /* speech synthesis not supported */
		msg = document.createElement('h5');
		msg.textContent = "Detected no support for Speech Synthesis";
		msg.style.textAlign = 'center';
		msg.style.backgroundColor = 'red';
		msg.style.color = 'white';
		msg.style.marginTop = msg.style.marginBottom = 0;
		document.body.insertBefore(msg, document.querySelector('div'));
	}

}
              
            
!
999px

Console