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.
<!-- Emmet Code:
doc>header>h1{Website Title}+nav>a{Link $}*3^^hr+aside#sidebar>h2{Sidebar Title}+p>Lorem^^main#blog>article.post(h1{Post Title $}+div.post-body(p*2>Lorem))*3
-->
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<header>
<h1>Website Title</h1>
<nav>
<a href="">Link 1</a></li>
<a href="">Link 2</a></li>
<a href="">Link 3</a></li>
</nav>
</header>
<hr>
<aside id="sidebar">
<h2>Sidebar Title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestiae deleniti tempore aliquam repudiandae est accusantium iste error! Facilis, sunt soluta totam eum! Laudantium pariatur minus ipsam quibusdam, quod saepe iure?</p>
</aside>
<main id="blog">
<article class="post">
<h1>Post Title 1</h1>
<div class="post-body">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum tempora, excepturi, laboriosam eligendi eveniet similique quod, saepe veniam id ducimus expedita vitae! Eius mollitia, earum molestias vero, numquam vel maxime.</p>
<p>Molestias, tenetur voluptate fugit, rerum optio id corporis eum, inventore asperiores deleniti aliquam qui voluptates, ipsam debitis reprehenderit! Molestiae atque possimus adipisci, itaque deserunt non obcaecati autem ipsam numquam commodi!</p>
</div>
</article>
<article class="post">
<h1>Post Title 2</h1>
<div class="post-body">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro, qui iste quisquam officiis obcaecati perferendis nam a expedita molestias ex dolores id laudantium, eius assumenda commodi suscipit, nisi quam. Nesciunt.</p>
<p>Pariatur, voluptatem dolor, quae aut eaque tempore mollitia quis in odit quaerat explicabo neque, dignissimos ullam iste tenetur commodi reiciendis numquam, necessitatibus! Suscipit recusandae id repellat, veritatis qui voluptate nobis.</p>
</div>
</article>
<article class="post">
<h1>Post Title 3</h1>
<div class="post-body">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Numquam eaque tenetur necessitatibus consequuntur, sed earum totam in laudantium nihil ab provident quas pariatur aliquam dolorem fugit. Odio ratione, aperiam dicta.</p>
<p>Quasi ipsum alias quis, maxime vero, eligendi possimus ex cum incidunt fuga neque dolorum ad atque accusantium beatae architecto earum quaerat, soluta culpa quibusdam. Voluptas ullam maxime quos recusandae pariatur.</p>
</div>
</article>
</main>
</body>
</html>
body {
line-height: 1.5;
}
aside h2, aside p {
padding: 0 5%;
margin-top: 30px;
}
aside h2,
header h1,
nav {
text-align: center;
}
header h1 { font-size: 250%; }
/* Helps with accessibility. */
nav {
font-size: 0;
margin-top: -20px;
}
nav a {
font-size: 18px;
background: #ddd;
padding: 5px;
margin: 0 5px;
}
main,
header {
max-width: 500px;
margin: 0 auto;
}
/* For screens smaller than 600 pixels wide. */
@media only screen and (max-width: 599.9px) {
aside {
display: none;
}
main,
header {
margin: 0 40px;
}
}
/* For screens larger than 600 pixels wide. */
@media only screen and (min-width: 600px) {
aside {
position: fixed;
width: 230px;
height: 100%;
top: 0;
left: 0;
background: #eee;
}
main,
header {
max-width: 500px;
padding-left: 240px;
margin: 0 auto;
}
}
/* Demonstrating the debugging hack. */
/* * {
background: #000!important;
color: #0f0!important;
outline: solid #f00 1px!important;
} */
/* Demonstrating the box model hack. */
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
}
Also see: Tab Triggers