Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

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.

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

              
                <!-- This is a comment in HTML -->
<html>
	<body>
		<h1>CSS Variables and CSS Grid</h1>
		<aside class="widget-area">
			<section class="widget widget-1">
				<h2 class="widget-title">Widget 1</h2>
				<p>CSS variables are fully supported. We can use them now. </p>
			</section>
			<section class="widget widget-2">
				<h2 class="widget-title">Widget 2</h2>
				<p>We have variables. Who says CSS isn't a real programming language?! </p>
			</section>
			<section class="widget widget-3">
				<h2 class="widget-title">Widget 3</h2>
				<p>CSS variables are fully supported. We can use them now. </p>
			</section>
			<section class="widget widget-4">
				<h2 class="widget-title">Widget 4</h2>
				<p>This widget is inheriting the background-color (--main-bg-color) that was declared on the "widget-area" class which overrides the same variable declared in the BODY element. </p>
			</section>
			<section class="widget widget-5">
				<h2 class="widget-title">Widget 5</h2>
				<p>CSS variables are fully supported. We can use them now. </p>
			</section>
			<section class="widget widget-6">
				<h2 class="widget-title">Widget 6</h2>
				<p>CSS Grid is now fully supported too (except for older IE). We can use grid layout now! </p>
			</section>
			<section class="widget widget-7">
				<h2 class="widget-title">Widget 7</h2>
				<p>The class for this widget is used twice (.widget-7.widget-7) in the CSS to override the "nth-child(odd)" pseudo selector. </p>
			</section>
		</aside>
		<p class="note">Notes: Learn about <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables">CSS Variables</a> and <a href="https://gridbyexample.com">CSS Grid</a>.</p>
		<footer class="my-footer">FOOTER - this is inheriting the "--main-bg-color" variable value declared in the BODY element; 		
		</footer>
	</body>
</html>

              
            
!

CSS

              
                /* This is a comment in CSS. It can go 
on multiple lines. */

html {
	font-size: 18px;
}
body { 
	color: #444444;
	font-size: 1rem;
	font-family: "Roboto", arial, sans-serif;
	--main-bg-color: pink; /* declare the variable */
}
.widget-area {
	padding: 1rem;
	display: grid;
	grid-template-columns: 1fr 300px 1fr;
	--main-bg-color: gray; /* this variable overrides the same one above */
	--secondary-bg-color: darkred; /* declare the variable */
	--tertiary-bg-color: darkgreen; /* declare the variable */
}
.widget {
	padding: 10px;
	background-color: var(--main-bg-color); 
	color: #333;
}
.widget:nth-child(odd) {
	background-color: blue;
	color: #fff; /* white */
}
.widget-6 {
	background-color: var(--secondary-bg-color); 
	color: white;
	grid-row: 2 / 4;
}
.widget-7.widget-7 {
	background-color: var(--tertiary-bg-color); 
	color: white;
	grid-column: span 2 / -1;
}
h2.widget-title {
	
}
.note {
	color: #888;
}
.my-footer {
	background-color: var(--main-bg-color);
	padding: 2rem;
}
              
            
!

JS

              
                
              
            
!
999px

Console