HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<!-- Header -->
<header class="banner">
<span class="background"></span>
<h1>Ken Burns Banner</h1>
</header>
<!-- Other stuff -->
<main>
<article>
<h1>Article</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ut enim lorem. Aenean consectetur magna quam, ac pharetra velit molestie vitae. Donec eros nisi, condimentum in nunc eget, rutrum faucibus orci. Aenean lacinia augue vel blandit ultricies. Quisque aliquet dui egestas consectetur aliquet. Etiam semper interdum sodales. Donec vehicula arcu rutrum nisi malesuada tincidunt convallis vitae magna. Nam in tortor commodo, molestie ligula vitae, volutpat justo.</p>
<p>Phasellus velit lectus, sagittis vitae nunc sit amet, elementum convallis nibh. Donec urna purus, faucibus a turpis a, blandit eleifend sem. Vivamus blandit, felis eu sodales cursus, elit mauris iaculis enim, quis volutpat purus massa in sapien. Fusce a enim felis. Aliquam in nulla leo. Aliquam at lacinia lectus. Nunc imperdiet dui in tortor tincidunt rutrum. Etiam porttitor metus convallis, ornare nisl a, interdum nisl. Integer lacinia quis enim nec ultrices. Mauris eget ante magna. Vestibulum volutpat adipiscing lorem et dignissim. Suspendisse sed semper ligula. Donec consequat auctor luctus. Quisque sodales, ipsum id facilisis cursus, lectus purus tincidunt massa, eu mollis odio odio ac dui. Suspendisse potenti.</p>
<p>Nam vitae ante in augue ultrices volutpat in non turpis. Ut mattis tellus vitae condimentum sagittis. Aenean porta nisi nulla, et sagittis odio consectetur vestibulum. Proin convallis felis ut nunc aliquam auctor. Praesent aliquet ut dui fermentum viverra. Curabitur tincidunt diam tellus, aliquet porttitor nisl accumsan ut. Fusce tincidunt lorem sit amet arcu porta consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse potenti. Maecenas aliquet neque a risus euismod faucibus. Aenean sit amet velit bibendum, iaculis orci in, interdum sem.
</p>
<p>Phasellus sed tortor eget odio eleifend congue non eu felis. Praesent cursus vehicula bibendum. Sed lacinia eget erat a mattis. Nulla et nisl nulla. Phasellus ac nisl augue. Sed erat quam, iaculis consectetur ante quis, imperdiet fermentum magna. Vivamus porttitor quis mi ac volutpat. Etiam libero nibh, varius id luctus sit amet, facilisis convallis erat. Nulla facilisi.</p>
</article>
</main>
/* Better box-sizing */
* { box-sizing: border-box; }
/* 1rem = 10px */
html { font-size: 62.5%; }
/* Default body */
body {
margin: 0;
opacity: 0;
font: 1.6rem/1.875 'Avenir Next', sans-serif;
}
/* Loaded body */
body.loaded {
opacity: 1;
transition: 1s opacity;
}
/* Default banner */
.banner {
position: relative;
width: 100%;
height: 40rem;
padding: 0 5%;
overflow: hidden;
backface-visibility: hidden;
}
/* Default image container */
.banner .background {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
z-index: -1;
transform: translate3d(0,0,0) scale(1.25);
background: black url(https://images.unsplash.com/photo-1531971085967-431db1ec65a2?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=212d5ac2d6b763d2f2168d4f0a85b36c&auto=format&fit=crop&w=2250&q=80) no-repeat center center;
background-size: cover;
}
/* Loaded image container */
.loaded .banner .background {
transform: scale(1);
transition: 6.5s transform;
}
/* Other stuff */
.banner h1 {
color: #EEE;
margin: 0;
line-height: 40rem;
text-transform: uppercase;
text-shadow: 0 0 .3rem black;
}
main {
width: 90%;
margin: 5rem auto;
}
main p { margin: 0 0 3rem 0; }
// Trigger class name on load
window.onload = function() {
document.body.className += ' loaded'
};
Also see: Tab Triggers