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 esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM 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.
<input type='checkbox' id='sideToggle1' hidden>
<input type='checkbox' id='sideToggle2' hidden>
<aside class='sideMenu left'>
<h2>Side Menu</h2>
<ul>
<li><a href='#' data-value='item 1'>item 1</a></li>
<li><a href='#' data-value='very long item 2'>very long item 2</a></li>
<li><a href='#' data-value='long item 3'>long item 3</a></li>
<li><a href='#' data-value='item 4'>item 4</a></li>
</ul>
</aside>
<aside class='sideMenu right'>
<h2>Side Menu</h2>
<ul>
<li><a href='#' data-value='item 1'>item 1</a></li>
<li><a href='#' data-value='very long item 2'>very long item 2</a></li>
<li><a href='#' data-value='long item 3'>long item 3</a></li>
<li><a href='#' data-value='item 4'>item 4</a></li>
</ul>
</aside>
<div id='contentWrap'>
<label class='menuBtn floatr' for='sideToggle2'>−</label>
<label class='menuBtn' for='sideToggle1'>−</label>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc feugiat sodales erat, nec fermentum risus interdum vitae. Suspendisse volutpat lectus id leo volutpat pulvinar. Aliquam sed mauris augue. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Praesent ligula purus, tincidunt vel aliquam ac, commodo sit amet lacus. Sed sapien arcu, venenatis eu tempus ac, egestas id nisl. In rhoncus vehicula velit, id pretium dolor tincidunt id. Sed fringilla eleifend felis, eget malesuada neque consectetur quis. Sed consequat, enim vel rhoncus tempor, arcu metus rhoncus enim, sit amet blandit velit elit nec leo. Suspendisse blandit felis in mi volutpat a tincidunt lectus tempor. Curabitur auctor lacinia varius. Proin condimentum dui eget arcu sagittis vitae sagittis quam porta. Etiam eleifend dui quis lorem volutpat rhoncus. Praesent nec enim et mauris scelerisque eleifend.
</p><p>
Pellentesque tristique tincidunt odio, ac interdum velit suscipit ut. Praesent nec odio id sem commodo iaculis. Donec nisi nisl, rutrum at auctor sit amet, tempus quis erat. Pellentesque rutrum urna ligula. Vivamus convallis, neque id condimentum semper, felis erat ultricies est, ut dignissim turpis lacus ut leo. Aenean nec quam ac diam tempor vestibulum in mollis felis. Phasellus malesuada ultricies urna, nec gravida nisl imperdiet sed. Morbi blandit dolor sed urna dapibus dictum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam erat volutpat. Praesent bibendum, nibh sed vehicula lobortis, mauris magna fringilla orci, viverra egestas arcu neque suscipit libero. Quisque lacus nisl, pretium blandit mollis in, vulputate a felis. Duis tincidunt mollis elit ac gravida. Aenean at sapien elit, ut facilisis neque.
</p><p>
Proin tempor adipiscing ligula, eget bibendum risus laoreet eget. Donec vitae nisl vitae eros imperdiet vestibulum nec sollicitudin est. Mauris ultrices augue id diam condimentum venenatis. Aenean ut felis odio. Nunc quis magna et ligula ullamcorper commodo vel vitae lectus. Mauris pulvinar pellentesque lobortis. Donec congue pretium pulvinar. Integer quis augue vel mi elementum sodales. Nam eget massa metus. Donec justo justo, vulputate id rhoncus a, tincidunt at arcu. Suspendisse vulputate eleifend pharetra.
<p><p>
Sed vitae luctus justo. Praesent placerat, augue eget imperdiet ullamcorper, mauris diam scelerisque nulla, quis ullamcorper purus risus ut leo. Suspendisse ornare rutrum lacus, non adipiscing massa rutrum non. Morbi in purus neque, quis ultricies augue. Aenean consequat, nisl ornare lacinia gravida, tortor lacus porta odio, in cursus tellus velit et ipsum. In hac habitasse platea dictumst. Nullam vel nisl risus. Morbi non tortor nibh.
</p><p>
Phasellus eleifend volutpat tristique. Nunc id mi a sem dignissim consequat. Cras eu enim eu magna sollicitudin varius. Vestibulum vel mi non lectus iaculis egestas. Vivamus quam augue, condimentum non consequat in, adipiscing eget metus. Integer est risus, pulvinar id facilisis et, semper vitae urna. Fusce lectus nulla, ultricies sed vulputate non, vulputate sollicitudin elit. Sed vehicula viverra elit aliquam sollicitudin. Vivamus venenatis fringilla sapien vel sagittis. Praesent congue scelerisque diam, a lobortis neque elementum ut. Curabitur eleifend bibendum auctor. Maecenas semper egestas est vitae auctor. Quisque interdum tincidunt tristique.
</p>
</div>
$sideNavWidth:250px;
$menuBG:#222;
$transition : .33s cubic-bezier(.7,.15,.36,1);
/* Reset */
*{ margin:0; padding:0; -moz-box-sizing:border-box; box-sizing:border-box; }
html{ height:100%; }
p{ padding:10px 0; }
body{ height:100%; font-family:arial; position:relative; background:$menuBG; overflow-x:hidden; }
.floatl{ float:left; }
.floatr{ float:right; }
/* Side menu */
.sideMenu{ position:fixed; top:0; bottom:0; z-index:0; width:$sideNavWidth; background:$menuBG; color:#FFF; padding:20px; text-transform:uppercase;
h2{ }
&.left{ opacity:.5; transform:translatex(-40px); transition:$transition; }
&.right{ left:auto; right:0; }
> ul{ padding:0; list-style:none; margin:20px 0;
> li{ border-top:1px solid rgba(255,255,255,0.1); position:relative; overflow:hidden;
a{ color:#CCC; text-decoration:none; display:block; line-height:3.2; font-size:0.8em; font-weight:bold; margin:0 -10px; padding:0 20px; overflow:hidden; white-space:nowrap; transition:.4s cubic-bezier(.3, .8, .5, 1.08);
&:hover{ color:$menuBG; text-indent:$sideNavWidth; }
&::before{ content:attr(data-value); color:#FFF; float:left; width:$sideNavWidth; margin-left:-$sideNavWidth; }
}
}
}
}
/* Toggle button */
.menuBtn{ display:inline-block; background:#f1103a; border-radius:50px; color:#FFF; cursor:pointer; display:block; font:bold 1.7em/36px Courier New; width:36px; height:36px; text-align:center; text-shadow:0 -5px, 0 5px; transition:0.15s;
&:hover{ background:#222; }
}
/* Content handing */
#contentWrap{ min-height:100%; position:relative; z-index:1; background:#FFF; padding:20px; transition:$transition;
#sideToggle1:checked ~ &{ border-radius:8px; transform:translatex($sideNavWidth); }
#sideToggle2:checked ~ &{ transform:translatex(-$sideNavWidth); border-radius:8px; }
}
#sideToggle1:checked ~ .sideMenu.left{ opacity:1; transform:none; }
Also see: Tab Triggers