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.


	<div class="video__wrapper">
		<video controls muted loop data-video>
			<source src="" type="video/mp4">
		<button class="video__btn" type="button" hidden data-btn aria-live="polite">Play</button>
	<figcaption class="video__caption">
		<a href="">Video by Lina Fresco from Pexels</a>



                * {
	box-sizing: border-box;

body {
	font-family: 'Helvetica', sans-serif;
	margin: 0;

video {
	width: 100%;
	display: block;

figure {
	margin: 0;

.video__wrapper {
	position: relative;
	max-width: 800px;

.video__wrapper::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: linear-gradient(-45deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 10%) 50%);

.video__btn {
	position: absolute;
	bottom: 1rem;
	right: 1rem;
	z-index: 1;
	border: none;
	border-radius: 0.4rem;
	padding: 0.7rem 1.5rem;
	min-width: 8rem;
	background-color: hsl(215, 84%, 53%);
	color: white;
	font-size: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 200ms;

.video__btn:is(:hover, :focus) {
	background-color: hsl(215, 84%, 35%);

.video__btn:is(:focus) {
	outline: 2px solid;
	outline-offset: 2px;

.video__caption {
	padding: 0.5rem;


                const btn = document.querySelector('[data-btn]')
const video = document.querySelector('[data-video]')

const noMotionPreference = window.matchMedia('(prefers-reduced-motion: no-preference)')

const initVideo = () => {
	// Remove default controls so we can add custom ones

	// Show custom play button
	btn.hidden = false
	// Set to autoplay only if user has no motion preference
	if (noMotionPreference.matches) {
		video.setAttribute('autoplay', true)
		btn.innerText = 'Pause'

btn.addEventListener('click', () => {
	// Toggle video playback
	if (video.paused) {
		btn.innerText = 'Pause'
	} else {
		btn.innerText = 'Play'