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

              
                <button class="play_btn">Click to Toggle Width</button>

<div class="window">
	<div class="top_bar">Browser Window</div>
	<div class="viewport">
		<div class="page">
			<div class="grid">
				<div class="card">
					<div class="card_content">
						Card content goes here. Lorem ipsum dolor sit amet.
					</div>
				</div>
				<div class="card">
					<div class="card_content">
						Card content goes here. Lorem ipsum dolor sit amet.
					</div>
				</div>
				<div class="card">
					<div class="card_content">
						Card content goes here. Lorem ipsum dolor sit amet.
					</div>
				</div>
				<div class="max_width_ruler">
					<b>Max-width</b> limits content while <b>padding</b> grows, crushing&nbsp;it.
				</div>
			</div>
		</div>
	</div>
</div>

              
            
!

CSS

              
                body {
	background-color: #eee;
}

body,
button {
	font-family: Montserrat, sans-serif;
}

.play_btn {
	font-weight: 700;
	padding: 20px 40px;
	font-size: 20px;
	cursor: pointer;
	background-color: #567;
	border: 2px solid #567;
	color: #fff;
	border-radius: 5px;
	transition: all 0.3s;
}

.play_btn:hover {
	background-color: #eff;
	color: #567;
}

.window {
	background-color: white;
	margin-top: 20px;
	border-radius: 5px;
	border: 2px solid #aaa;
	overflow: auto;
	width: 60%;
	transition: width 1s;
}

.window_wide {
	width: 100%;
}

.window_wide .card {
	background-color: red;
}

.top_bar {
	padding: 5px 20px;
	background-color: #ddd;
	text-align: center;
	font-weight: 700;
}

.viewport {
	container-type: inline-size;
}

.page {
	padding: 40px 20px;
}

.grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 20px;
	max-width: 400px;
	margin: 0 auto;
	font-size: 12px;
}

.card {
	border: 10px solid orange;
	padding: 4cqw;
	background-color: white;
	transition: background-color 1s;
}

.card_content {
	background-color: #fff;
}

.max_width_ruler {
	background: lightblue;
	padding: 5px 10px;
	grid-column: 1 / 4;
	text-align: center;
	font-size: 16px;
}

              
            
!

JS

              
                const pretendWindow = document.querySelector('.window');
const playButton = document.querySelector('.play_btn');

playButton.addEventListener('click', () => {
	pretendWindow.classList.toggle('window_wide');
});
              
            
!
999px

Console