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.
<header class="site-header"></header>
<nav class="site-nav">
<div class="wrapper">
<ul>
<li><a class="active" href="#" tabindex="2">Link 1</a></li>
<li><a href="#" tabindex="3">Link 2</a></li>
<li><a href="#" tabindex="4">Link 3</a></li>
<li><a href="#" tabindex="5">Link 4</a></li>
<li class="search-trigger-container"><a href="#" id="search-trigger" class="search-trigger" tabindex="5">Search</a></li>
</ul>
</div>
</nav>
<div class="content wrapper">
<!-- start slipsum code -->
<h1>Are you ready for the truth?</h1>
<p>The path of the righteous man is beset on all sides by the iniquities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy My brothers. And you will know My name is the Lord when I lay My vengeance upon thee. </p>
<h1>Is she dead, yes or no?</h1>
<p>You think water moves fast? You should see ice. It moves like it has a mind. Like it knows it killed the world once and got a taste for murder. After the avalanche, it took us a week to climb out. Now, I don't know exactly when we turned on each other, but I know that seven of us survived the slide... and only five made it out. Now we took an oath, that I'm breaking now. We said we'd say it was the snow that killed the other two, but it wasn't. Nature is lethal but it doesn't hold a candle to man. </p>
<h1>I took lessons</h1>
<p>Now that we know who you are, I know who I am. I'm not a mistake! It all makes sense! In a comic, you know how you can tell who the arch-villain's going to be? He's the exact opposite of the hero. And most times they're friends, like you and me! I should've known way back when... You know why, David? Because of the kids. They called me Mr Glass. </p>
<h1>We happy?</h1>
<p>Now that we know who you are, I know who I am. I'm not a mistake! It all makes sense! In a comic, you know how you can tell who the arch-villain's going to be? He's the exact opposite of the hero. And most times they're friends, like you and me! I should've known way back when... You know why, David? Because of the kids. They called me Mr Glass. </p>
<h1>Are you ready for the truth?</h1>
<p>Like you, I used to think the world was this great place where everybody lived by the same standards I did, then some kid with a nail showed me I was living in his world, a world where chaos rules not order, a world where righteousness is not rewarded. That's Cesar's world, and if you're not willing to play by his rules, then you're gonna have to pay the price. </p>
<!-- please do not remove this line -->
<div style="display:none;">
<a href="http://slipsum.com">lorem ipsum</a></div>
<!-- end slipsum code -->
</div>
@import url(https://fonts.googleapis.com/css?family=Merriweather:700,900);
@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,400,600,700,900);
h1, p { margin-bottom: 1.25em; max-width: 700px; }
h1 { font-family: Merriweather; font-weight: 900; }
p { font-size: 0.8rem; line-height: 1.75em; }
html {
background: #000;
font-size: 140%;
line-height: 1.7em;
}
body {
background-color: #eee;
color: #444;
font-family: 'Source Sans Pro';
font-size: inherit;
font-weight: 400;
min-height: 1000px;
padding: 100px 0 0;
transition: background-color 350ms ease-in-out;
}
body.sticky { background-color: #eee; }
.wrapper {
background: #fafafa;
margin: auto;
padding: 0 30px;
max-width: 1140px;
}
.site-nav {
background: transparent;
box-shadow: 0 5px 5px -2px rgba(0, 0, 0, 0),0px 1px 8px 0px rgba(0, 0, 0, 0);
min-height: 80px;
transition: background-color 220ms ease-in, box-shadow 80ms ease-in;
}
.site-nav .wrapper { background: #fafafa; height: 40px; padding: 20px 30px; transition: background-color 100ms ease-in-out; }
nav ul { display: block; float: left; list-style: none; margin: 0; padding: 0; width: 100%; }
.site-nav li { display: block; float: left; height: 100%; line-height: 100%; margin: 0 20px 10px 0; }
.site-nav a {
border-bottom: 5px solid transparent;
color: #666;
display: block;
font-family: 'Source Sans Pro';
font-weight: 200;
font-size: 1.05rem;
height: 43px;
line-height: 45px;
padding: 0 2px;
text-align: center;
text-decoration: none;
text-transform: uppercase;
transition: all 200ms ease-out;
outline-width: 0;
}
.sticky .site-nav a {
color: #888;
}
.site-nav a:focus,
.site-nav a:hover,
.site-nav a.active:focus,
.site-nav a.active:hover,
.site-nav .wrapper:hover a.active:focus,
.site-nav .wrapper:hover a.active:hover,
.pages a:focus,
.pages a:hover,
.pages a.current:focus,
.pages a.current:hover {
border-color: #CF0404;
border-width: 2px;
color: #444;
position: relative;
top: -1px;
}
.site-nav .wrapper:hover a {
color: transparent;
text-shadow: 0 0 4px rgba(0,0,0,.5);
}
.site-nav .wrapper:hover a:focus,
.site-nav .wrapper:hover a:hover,
.site-nav .wrapper:hover a.active,
.site-nav .wrapper:hover a.active:focus,
.site-nav .wrapper:hover a.active:hover {
color: #333;
text-shadow: none;
}
.site-nav .wrapper:hover a.active {
color: transparent;
text-shadow: 0 0 4px rgba(0,0,0,.5);
}
.site-nav a.active,
.pages a.current {
border-color: #333 ;
border-width: 2px;
color: #444;
font-weight: 400;
}
.site-nav a:active,
.site-nav a.active:active,
.pages a:active,
.pages a.current:active {
border-color: #CF0404;
border-width: 4px;
top: 1px;
}
.sticky .site-header { margin-bottom: 80px; }
.sticky .site-nav {
background: rgba(255,255,255,.8);
box-shadow: 0 5px 5px -2px rgba(0, 0, 0, 0.1),0px 1px 8px 0px rgba(0, 0, 0, .6);
margin: -180px 0 0;
position:fixed;
width:100%;
z-index: 1000;
}
.sticky .site-nav .wrapper {
background: rgba(250, 250, 250, 0.75);
}
.site-nav li.search-trigger-container {
float: right;
}
#search-trigger {
background-color: transparent;
border: none;
border-radius: 50%;
box-shadow: none;
display: block;
height: 44px;
margin: 0;
padding: 0;
position: relative;
text-indent: -9999em;
top: -2px;
transition: background-color 250ms ease-out, box-shadow 200ms ease-out, transform 200ms linear;
width: 44px;
}
#search-trigger:before {
background-color: inherit;
border: 3px solid #333;
border-radius: 50%;
content: ' ';
display: block;
height: 16px;
position: absolute;
right: 8px;
top: 8px;
transition: border-color 200ms ease-out;
width: 16px;
}
#search-trigger:after {
background: #333;
border-radius: 2px;
bottom: 14px;
content: ' ';
display: block;
height: 3px;
left: 8px;
position: absolute;
transform: rotate(-45deg);
transition: background 200ms ease-out;
width: 12px;
}
#search-trigger:focus,
#search-trigger:hover {
background-color: #404040;
transform: scale(1);
}
#search-trigger:hover:before {
border-color: #fff;
}
#search-trigger:hover:after {
background-color: #fff;
}
#search-trigger:active {
box-shadow: 0 0 2px -2px rgba(0,0,0,.3);
transform: scale(.9);
}
.content {
min-height: 1140px;
padding-top: 30px;
}
$(function() {
$(document).bind('ready scroll', function() {
var docScroll = $(document).scrollTop();
if (docScroll >= 100 & $('html').height() > 768) {
if (!$('body').hasClass('sticky')) {
$('body').addClass('sticky');
}
} else {
$('body').removeClass('sticky');
$('.site-nav').removeAttr('style');
}
});
$('.site-nav a').click(function(e){
if(!$(this).hasClass('search-trigger'))
{
$('.site-nav a.active').removeClass('active');
$(this).addClass('active');
}
$(this).blur()
e.preventDefault();
});
});
Also see: Tab Triggers