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.
<main>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Sequi, at odit. Dolores reiciendis excepturi repellat!</p>
<details open>
<summary>Table of Contents</summary>
<div class="toc-contents">
<ul>
<li><a href="">Item 1</a></li>
<li><a href="">Item 2</a></li>
<li><a href="">Item 3</a></li>
<li><a href="">Item 4</a></li>
<li><a href="">Item 5</a></li>
<li><a href="">Item 6</a></li>
<li><a href="">Item 7</a></li>
<li><a href="">Item 8</a></li>
</ul>
</div>
</details>
<p>Repellendus, officiis error nisi, dolorum, eos vitae consectetur veritatis similique voluptatum sint dignissimos dolores molestias!</p>
<p>Earum, adipisci ad. Debitis ipsa beatae a quaerat dolore optio possimus nulla praesentium eveniet pariatur?</p>
<p>Nostrum reiciendis aperiam consectetur neque, sit voluptatum, distinctio modi architecto eius id, commodi porro! Asperiores.</p>
<p>Error quis, corporis vitae dolores veritatis perspiciatis id impedit quod nostrum, incidunt sed explicabo minima!</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempora magnam sit, deserunt dolorum provident inventore laboriosam?</p>
<p>Aspernatur, eos at possimus saepe illum molestias ad tenetur debitis quas error illo voluptate amet asperiores.</p>
<p>Magni voluptates consectetur iure nihil voluptas dicta pariatur, distinctio nostrum! Modi esse aperiam quae ipsam voluptatum!</p>
<p>Officiis dolores sit quisquam tempore in molestiae nemo error. Quasi corporis culpa molestiae deleniti ullam itaque.</p>
<p>Delectus, vitae? Nostrum, ex. Quam corrupti dignissimos velit eligendi perferendis omnis alias maxime itaque laudantium laboriosam.</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Autem nemo qui dolorum, pariatur corporis modi eum a explicabo unde placeat, laborum accusantium. Officiis cumque rerum pariatur accusamus delectus quos amet?</p>
<p>Sit iure porro ullam in perspiciatis adipisci placeat magnam deserunt et? Harum consequuntur eaque facilis quos tempore ipsam, impedit explicabo repellat qui eligendi nulla esse? Perferendis at suscipit recusandae mollitia?</p>
<p>Consequatur veniam, saepe pariatur ratione fugiat a ducimus eius autem! Fugiat molestias aspernatur, vero cupiditate odio quia aut facere repellendus, maxime debitis repellat officia ipsam quibusdam sed voluptatibus officiis adipisci.</p>
<p>Eveniet assumenda soluta rerum labore molestiae sapiente, vel dolores veritatis harum consequatur impedit? Quaerat reiciendis error deleniti? Obcaecati, quibusdam! Tempora cupiditate alias officia. Rerum in vel voluptate quos, itaque facilis.</p>
<p>Nemo, delectus, hic aliquam laudantium voluptates, tenetur eligendi pariatur molestias eaque odio commodi voluptatibus cum. Sint, omnis. Alias expedita iste doloremque, a quisquam voluptatum soluta magnam aspernatur facilis inventore omnis?</p>
<p>Totam, rem ducimus fuga animi esse iusto! Quas corrupti eligendi sequi maiores pariatur ad esse, doloremque quae placeat. Nisi assumenda dolor sunt. Pariatur nesciunt ex minus unde mollitia, ratione eos.</p>
<p>Eos voluptas fugiat nulla non commodi iure dicta molestias ipsum corporis. Autem nisi veritatis quam provident, repellat accusantium numquam quia minus excepturi, laboriosam tenetur. Odio dolorem consequatur alias unde? Magnam?</p>
<p>Nam doloremque non magni aperiam dicta mollitia ducimus? Voluptatem earum, id natus reiciendis minima a obcaecati laboriosam dolorum ipsa nulla assumenda hic animi ex fuga? Eligendi obcaecati libero provident neque.</p>
</main>
.toc-contents {
overscroll-behavior: contain;
max-height: 5.5em;
overflow-y: auto;
}
details {
float: left;
margin-right: 1rem;
padding: 1rem;
box-shadow: 0 0 8px -2px hsl(0 0% 45%);
border-radius: 0.5rem;
}
* {
box-sizing: border-box;
margin: 0;
}
body {
font-family: system-ui;
line-height: 1.5;
padding: 5vmin;
}
main {
max-width: 60ch;
margin-inline: auto;
}
main > * + * {
margin-top: 1em;
}
Also see: Tab Triggers