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="header sticky sticky--top js-header">
<div class="grid">
<nav class="navigation">
<ul class="navigation__list navigation__list--inline">
<li class="navigation__item"><a href="#" class="navigation__link navigation__link--is-active">Home</a></li>
<li class="navigation__item"><a href="#" class="navigation__link">About Us</a></li>
<li class="navigation__item"><a href="#" class="navigation__link">Work</a></li>
<li class="navigation__item"><a href="#" class="navigation__link">Clients</a></li>
<li class="navigation__item"><a href="#" class="navigation__link">Contact</a></li>
</ul>
</nav>
</div>
</header>
<main class="main">
<div class="grid">
<h1>Lorem ipsum dolor sit.</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Id sed voluptatem error vel eius placeat harum voluptate doloribus ratione in, vero aliquid et, itaque, repellat magnam nisi adipisci unde, odit esse architecto hic! Eaque libero officia laudantium laboriosam non velit vero pariatur, rem nisi commodi dolores, culpa quibusdam dolorem nemo voluptatem. Ipsam, molestias autem iste est quia magni iusto distinctio esse magnam possimus tenetur dolor, suscipit fugiat ad? Natus officia magnam ipsam. Nisi aut quis natus voluptatum, sapiente inventore quidem similique odio, quod iste delectus commodi maxime asperiores doloribus officiis fuga, eaque, beatae ipsam assumenda architecto. At minima pariatur qui!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatem numquam sint nisi natus fugiat quibusdam, iusto unde tenetur consequuntur, dolorum laborum consectetur explicabo at blanditiis aperiam perferendis totam neque vitae eos quisquam, ratione cum id fuga? Ad harum dolores optio debitis, eaque excepturi, iste totam. Quasi, maiores eligendi laudantium nobis harum ullam nihil voluptas officia id molestiae animi deleniti placeat dolorum atque fuga. Mollitia ducimus corporis natus doloribus blanditiis, voluptatem officia nesciunt sit dolorem incidunt illum vel voluptas, exercitationem nemo repellendus deleniti! Vero rerum natus blanditiis voluptatibus nihil deserunt, vitae nulla reprehenderit perferendis praesentium minus, dolor consequuntur repellat repudiandae, facilis veritatis dolorem? Nisi magni dolor, ut maiores voluptas rem amet commodi est distinctio perferendis mollitia dicta dolores, officiis dignissimos dolorem ea soluta ex quae nemo. Cupiditate ab ratione voluptatem non impedit, tempora voluptas ipsam iste sed a, animi sunt veniam deserunt molestias nobis excepturi. Earum inventore vitae recusandae, sint. Aut.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nemo magni maxime rerum minus impedit autem explicabo ex eius perspiciatis libero ipsam ab harum maiores rem aliquid inventore, dolor optio quas, temporibus, deleniti soluta expedita similique. Aperiam ad quasi sed officia dolorem, consectetur ipsum, vel possimus fugiat expedita adipisci, porro ea inventore accusantium, blanditiis nam minus. Laudantium similique amet et odio culpa quibusdam vel doloremque voluptatem totam a sit blanditiis placeat, beatae quasi esse dicta, earum alias delectus hic libero magni ipsam eveniet tempore. Inventore vitae error, provident ipsum quidem atque, tempora laboriosam at totam unde illo eligendi magnam reiciendis nam magni ut, laudantium deserunt odio voluptatibus maiores facilis. Voluptas ea consectetur, totam non possimus laudantium at quibusdam nihil doloribus, porro ipsum qui animi itaque velit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nulla adipisci a vero sint ducimus provident quas, eveniet tenetur, corporis ex quidem aliquam consequatur quam dicta dolores modi nisi dolorem magnam, consequuntur quasi assumenda saepe similique eos accusantium, odio! Excepturi illo corporis, magni eaque animi esse, odit minima expedita facilis repellendus, culpa magnam eius delectus consequatur tenetur. Totam magnam voluptate mollitia quod omnis, hic, labore, veniam molestiae amet, quam distinctio optio nobis tenetur similique blanditiis. Fugiat obcaecati repudiandae culpa totam quasi perspiciatis rerum quibusdam architecto asperiores, enim quisquam error numquam officiis, voluptatibus debitis vitae sint. Neque ipsam, nobis sunt ut consectetur. Doloremque velit quasi necessitatibus inventore earum rem enim omnis aut doloribus laboriosam accusamus consequatur libero facere vitae dolorem mollitia voluptates molestias fugiat laborum dignissimos esse, nesciunt totam, blanditiis accusantium! Provident perspiciatis deserunt nostrum. Et provident optio enim perspiciatis tenetur distinctio officia, molestias in repellendus eius quis tempora animi. Reprehenderit, veniam.</p>
</div>
</main>
@use postcss-preset-env {
stage: 0;
}
/* helpers/grid.css */
.grid {
inline-size: 90%;
margin-inline: auto;
max-inline-size: 48em;
}
/* helpers/sticky.css */
.sticky {
position: sticky;
will-change: transform;
}
.sticky--top {
top: 0;
}
/* layout/base.css */
* {
box-sizing: inherit;
}
html {
box-sizing: border-box;
}
body {
font-family: 'Roboto', sans-serif;
line-height: 1.75;
margin: 0;
min-block-size: 100vh;
}
/* layout/header.css */
.header {
background-color: #fff;
padding-block: 1em;
}
.header::after {
bottom: 0;
box-shadow: 0 0.0625em 0.5em rgba(0, 0, 0, 0.3);
content: '';
left: 0;
opacity: 0;
position: absolute;
right: 0;
top: 0;
transition: opacity 0.3s;
z-index: -1;
}
.header.is-active::after {
opacity: 1;
}
/* layout/main.css */
.main {
padding-block: 6em;
}
/* modules/headline.css */
h1 {
margin-block: 0 0.5em;
}
/* modules/navigation.css */
.navigation__list {
list-style: none;
margin: 0;
padding: 0;
}
.navigation__list--inline {
display: flex;
gap: 1.5em;
}
.navigation__link {
color: inherit;
display: block;
padding-inline: 1em;
text-decoration: none;
}
.navigation__link--is-active {
background-color: #000;
border-radius: 999em;
color: #fff;
}
/* modules/paragraph.css */
p {
padding-block: 1.5em;
}
import throttle from "https://cdn.skypack.dev/lodash@4/throttle";
function onScroll() {
if (window.pageYOffset) {
$$header.classList.add("is-active");
} else {
$$header.classList.remove("is-active");
}
}
const $$header = document.querySelector(".js-header");
window.addEventListener("scroll", throttle(onScroll, 300));
Also see: Tab Triggers