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.
<!-- Skip to Content Link -->
<a href="#content" class="sr">Jump to the main content</a>
<!-- Navigation Toggle Button -->
<a href="#nav" class="nb" title="Jump to the main navigation" role="button">Menu</a>
<!-- Header -->
<header class="h" role="banner">
<h1 id="logo"><a href="#"><img src="http://placehold.it/260x68" alt="Your Logo" /></a></h1>
</header>
<!-- Mobile Navigation -->
<nav id="nav" class="nav" role="navigation">
<ul class="navul">
<li><a href="#">Link One</a></li>
<li><a href="#">Link Two</a></li>
<li><a href="#">Link Three</a></li>
<li><a href="#">Link Four</a></li>
<li><a href="#">Link Five</a></li>
</ul>
</nav>
<!-- Nav Closing Button -->
<a href="#top" class="nc" role="button" title="Jump back to the start of the document">X</a>
<!-- Main Content -->
<main class="m" role="main">
<section id="content">
<h1>Precious Contents</h1>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
</section>
</main>
/* Font Setting */
html {
font-family: Verdana, Helvetica, Arial, sans-serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
/*
IE is always having a private party and YOU are not invited.
Yeah, well, since SNAP mode was invented for Windows 8 there have been a few front end developers cursing, shouting and tossing tables:
(╯°□°)╯︵ ┻━┻
Thing is... Win8s IE10 and 11 are different on a desktop computer compared to what they do on a mobile device with Win8.
*/
@-ms-viewport {
width: device-width;
}
body {
line-height: 1.46;
overflow-x: hidden;
color: #333;
margin: 0;
background: #999;
}
/**
* Correct `block` display not defined for any HTML5 element in IE 8/9.
*/
header,
nav {
display: block;
}
/**
* Remove the gray background color from active links in IE 10.
*/
a {
font-size: 100%;
text-decoration: none;
margin: 0;
background: transparent;
color: #fff;
}
/**
* Improve readability of focused elements when they are also in an
* active/hover state.
*/
a:active,
a:hover {
outline: 0;
}
/*
If you want to overwrite the default tap-highlight-color
you can define one for your project but keep in mind to make it
an RGBA color with a little transparency so the text won't
become unreadable after the tap.
This also has an effect on old Android (2.3). I know because
I still own one of those.
*/
a:link {
-webkit-tap-highlight-color: rgba(255, 255, 255, .4);
}
h1 {
font-size: 1em;
margin: 0;
}
ul {
list-style: none;
padding: 0;
}
/**
* Remove border when inside `a` element in IE 8/9/10.
*/
img {
border: 0;
max-width: 100%;
height: auto; /* for safety reasons */
}
/** Helpers **/
/** Invisible but readable for screenreaders
* This solution has helped me best at hiding contents in favor of images and keep text accessible.
*/
.sr {
display: block;
text-indent: 120%;
overflow: hidden;
white-space: nowrap;
height: .008em;
width: .008em;
}
/* Mobile First Styling */
/**
* Header
*/
.h {
z-index: 3;
width: 38.2%;
margin-left: 5.5%;
padding: 1.25em 0;
}
/** Navigation Toggle Button and Closing Button **/
.nb,
.nc {
font-weight: 700;
text-transform: uppercase;
position: absolute;
right: 1.5em;
top: 1.75em;
z-index: 4;
padding: .4em;
color: #fff;
background: #ccc;
border-radius: .25em;
border: .08em solid rgba(0,0,0,.25);
box-shadow: 0 .08em .08em rgba(0, 0, 0, .25);
}
.nb:active,
.nc:active {
background: #999;
box-shadow: 0 .08em .08em rgba(255, 255, 255, .65), 0 -.08em .08em rgba(255, 255, 255, .65);
}
/* Normally the closing button is hidden */
.nc {
display: none;
z-index: 3;
}
/* and as soon as the nav is targeted we reveal it and place it on top of the menu button */
.nav:target + .nc {
display: block;
z-index: 5;
padding: .38em 1.65em;
}
/** Mobile Navigation Styling
* The container is at 0 height at first
* when receiving target everything becomes
* visible by giving it height and display: block
*/
.nav {
position: absolute;
display: block;
width: 100%;
height: 0px;
max-height: 0px;
padding-top: 0px;
opacity: 0;
transition: none ;
}
.nav ul {
display: none;
margin: 0;
}
.nav li {
line-height: 1.65;
padding: 0 .3275em;
}
.nav a {
display: block;
padding: 0;
width: 0;
height: 0;
}
/** When clicking the Menu button the nav receives :target
*/
.nav:target {
position: relative;
top: -10em;
z-index: 2;
padding-top: 10em;
margin-bottom: -8em;
height: 100%;
max-height: 62.5em;
opacity: 1;
transition:
opacity .4s ease-out,
max-height .4s ease-out;
}
.nav:target ul {
display: block;
margin: 1em 5.5%;
}
.nav:target a {
width: auto;
height: 100%;
padding: .3875em 0 .3875em .5475em;
border-bottom: 0.08em solid rgba(0, 0, 0, 0.25);
}
.nav:target a:hover,
.nav:target a:focus {
background-color: #aaa;
}
.nav:target a:active {
color: #999;
background-color: #fff;
}
/** Main Content Area
*/
.m {
background: #fff;
box-shadow: 0 0 .625em .08em rgba(0, 0, 0, .05);
padding: 1.75em 5.5% 2em;
}
Also see: Tab Triggers