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>
<span id="toggle">Toggle Grid</span>
<span id="palette-1" class="active">Palette 1</span>
<span id="palette-2">Palette 2</span>
<span id="palette-3">Palette 3</span>
<span id="palette-4">Palette 4</span>
<span id="palette-5">Palette 5</span>
</header>
<div class="container">
<div class="main-col">
<h1>Lorem ipsum dolor sit amet</h1>
<p class="caption">Labore reprehenderit corporis ullam distinctio ex.</p>
<p>Consectetur adipisicing elit, alias at autem magna aliquid <a href="#">quam proident</a> quis aliquam. temporibus minus eius veniam cupidatat ex, voluptas fuga, quos, mollitia incidunt do officia facilis. molestiae consequat excepturi laborum perferendis tempor minim eiusmod minim minus quia sint.</p>
<p class="caption sidenote">Maiores at duis consequatur corrupti.</p>
<p>Quos atque officia quod. <i>Suscipit delectus</i> cupidatat, quia nulla numquam aute cillum proident. Maiores iusto culpa molestias quam id tenetur saepe impedit reiciendis itaque ducimus itaque nostrud. Tempor aliquip, culpa earum itaque sed consequatur minus aliquip reprehenderit nihil veniam tempora do maxime omnis reiciendis elit tempora.</p>
<ol>
<li>Perferendis tempor</li>
<li>Minim eiusmod </li>
<li>Tempor</li>
<li>Minus quia sint</li>
</ol>
</div>
<div class="main-col">
<h2>Voluptates mollitia</h2>
<p>Proident dolores corrupti consequatur voluptatibus labore commodi quos. <b>Incidunt mollitia</b> tempora assumenda laborum voluptate accusamus dolore optio incididunt. Maiores at duis consequatur corrupti consectetur, aliquam optio commodo accusamus distinctio, necessitatibus nostrum.</p>
<p>Optio, nesciunt, quo, fugiat, blanditiis at quas excepturi quae maiores vel corrupti voluptate cupiditate nemo! In, eius quidem harum quibusdam ratione non. Iste, deleniti, fugit, voluptas aperiam qui adipisci provident ab accusantium possimus eveniet voluptate consectetur!</p>
<h2>Repellat optio</h2>
<h3>Ad perferendis omnis</h3>
<p>Pariatur animi quis. Dolorem cupiditate <a href="#">praesentium duis</a> iusto corrupti nobis nostrud, exercitation consequatur. Nulla minim dignissimos reprehenderit voluptatem. Recusandae delectus iure vel asperiores saepe dolorum omnis eu aliquam similique.</p>
<blockquote><p>Fuga rerum laboris officia cupidatat, excepteur aliquid ut quis facere, cumque harum optio dignissimos. Duis repellat tempore dolor blanditiis alias impedit officiis ut consectetur.</p></blockquote>
<h4>Quibusdam illum quo</h4>
<p>Quos laboris eos, laborum animi. Ea blanditiis ducimus fugiat officia nostrud consectetur recusandae excepteur. Quis qui maiores distinctio facilis saepe eos.</p>
<pre><code>body {
color: blue;
}</code></pre>
</div>
<div class="sidebar">
<h3>Consectetur</h3>
<p>Iure vel nostrud repellendus. <b>Nostrud</b> autem consequatur, provident officiis qui, mollit exercitation.</p>
</div>
<div class="main-col">
<p>Corporis eligendi minim, enim proident reprehenderit iusto. <i>Reprehenderit</i> commodo commodi, repudiandae voluptas saepe sint libero. Praesentium eius distinctio ullamco vero iusto praesentium eligendi animi. Consectetur dolore vero similique dolore, ut labore omnis.</p>
<h6>Maxime alias anim similique</h6>
<p>Omnis corporis assumenda nisi ullam dolores culpa repellat. Molestias praesentium necessitatibus minus, reiciendis officiis commodo incidunt. Consectetur nostrud odio numquam tenetur.</p>
<hr>
<h1>Heading level 1</h1>
<h2>Heading level 2</h2>
<h3>Heading level 3</h3>
<h4>Heading level 4</h4>
<h5>Heading level 5</h5>
<h6>Heading level 6</h6>
<p>Paragraph with <b>bold</b>, <i>italic</i>, <a href="#">link</a> and <code>code</code> styles.</p>
<blockquote><p>Blockquote</p></blockquote>
<p class="caption">Caption text</p>
<ol>
<li>Ordered list element one</li>
<li>Ordered list element two</li>
<li>Ordered list element three</li>
</ol>
<ul>
<li>Unordered list element one</li>
<li>Unordered list element two</li>
<li>Unordered list element three</li>
</ul>
</div>
</div>
/* Demo web fonts from Adobe Fonts */
@import url("https://use.typekit.net/swm2ywc.css");
/* Font palettes */
body, body.palette-1 {
--head-fonts: verdana, sans-serif;
--body-fonts: georgia, serif;
--code-fonts: calling-code, monospace;
}
body.palette-2 {
--head-fonts: -apple-system, BlinkMacSystemFont, Aptos, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
--body-fonts: -apple-system-ui-serif, ui-serif, "Noto Serif", "Times New Roman", serif;
--code-fonts: ui-monospace, SFMono-Regular, ui-monospace, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
}
body.palette-3 {
--head-fonts: brandon-grotesque, sans-serif;
--body-fonts: elmhurst, serif;
--code-fonts: calling-code, monospace;
}
body.palette-4 {
--head-fonts: ff-tisa-sans-web-pro, sans-serif;
--body-fonts: karmina, serif;
--code-fonts: source-code-pro, monospace;
}
body.palette-5 {
--head-fonts: delittle-chromatic, sans-serif;
--body-fonts: omnes-pro, sans-serif;
--code-fonts: logic-monoscript, monospace;
}
/* Set baseline size */
:root {
font-size: 100%;
}
/* Show baseline grid */
html.show-grid body {
background-image: linear-gradient(to bottom, #0ff 0, transparent 1px);
background-repeat: repeat-y;
background-size: 100% 1rem;
}
/* Set headings to baseline */
h1, h2, h3, h4, h5, h6 {
--baselines: 3;
--beneath: 1;
--baseline-shift: calc(calc(calc(var(--baselines) * 1rem) - 1cap) / 2);
--baseline-push: calc(calc(var(--beneath) * 1rem) - var(--baseline-shift));
font-family: var(--head-fonts);
font-weight: 700;
line-height: calc(var(--baselines) * 1rem);
margin: 0;
padding: 0;
font-feature-settings: 'kern', 'lnum', 'liga';
padding-top: var(--baseline-shift);
margin-bottom: var(--baseline-push);
}
h4, h5, h6 {
--baselines: 2;
--beneath: 0;
}
/* Set text to baseline */
p, ul, ol {
--baselines: 2;
--beneath: 1;
--baseline-shift: calc(calc(calc(var(--baselines) * 1rem) - 1cap) / 2);
--baseline-push: calc(calc(var(--beneath) * 1rem) - var(--baseline-shift));
font-family: var(--body-fonts);
font-size: 1.2rem;
line-height: calc(var(--baselines) * 1rem);
margin: 0;
padding: 0;
font-feature-settings: 'kern', 'onum', 'liga';
padding-top: var(--baseline-shift);
margin-bottom: var(--baseline-push);
}
p + h1, ul + h1, ol + h1,
p + h2, ul + h2, ol + h2,
p + h3, ul + h3, ol + h3 {
padding-top: calc(var(--baseline-shift) + 1rem);
}
/* Heading sizing modular scale */
h1 {
font-size: 2.986rem;
}
h2 {
font-size: 2.488rem;
}
h3 {
font-size: 2.074rem;
}
h4 {
font-size: 1.728rem;
}
h5 {
font-size: 1.44rem;
}
h6 {
font-size: 1.2rem;
}
/* Additional typographic element styling */
.caption {
font-size: 1rem;
}
h1 + .caption, h2 + .caption, h3 + .caption {
margin-top: -1rem;
}
.sidenote {
left: 65%;
width: 35%;
padding-left: 4rem;
position: absolute;
max-width: 35%;
}
code, pre {
font-family: var(--code-fonts);
}
pre {
background-color: rgba(245, 245, 215, 0.5);
display: block;
margin-bottom: 2rem;
padding: 1rem;
white-space: pre;
white-space: pre-wrap;
word-break: break-all;
word-wrap: break-word;
}
code {
line-height: 1rem;
}
blockquote {
p {
border-left: 0.15rem solid blue;
font-style: italic;
padding-left: 1rem;
padding-bottom: calc(calc(var(--beneath) * 1rem) - calc(calc(calc(var(--baselines) * 1rem) - 1cap) / 2));
margin-bottom: 1rem;
}
}
b, strong {
font-weight: 700;
}
em, i {
font-style: italic;
}
ul, ol {
li {
ol, ul {
padding-top: 1rem;
margin-bottom: 1rem;
margin-left: 2rem;
}
}
}
ul {
list-style-type: disc;
}
ol {
list-style-type: none;
li {
counter-increment: top-level;
&:before {
content: counter(top-level) '.';
font-feature-settings: 'lnum', 'tnum';
margin-left: -3rem;
position: absolute;
text-align: right;
width: 2em;
}
ul {
li {
&:before {
content: '';
}
ol {
li {
counter-increment: alt-level;
&:before {
content: counter(alt-level) '.';
}
}
}
}
}
ol {
li {
counter-increment: sub-level;
&:before {
content: counter(top-level) '.' counter(sub-level);
}
ul {
li {
&:before {
content: '';
}
}
}
ol {
li {
counter-increment: sub-sub-level;
&:before {
content: counter(top-level) '.' counter(sub-level) '.' counter(sub-sub-level);
}
}
}
}
}
}
}
hr {
background-image: linear-gradient(to bottom,rgba(0, 0, 0, 0) 50%,gray 50%);
background-position: 0 50%;
background-repeat: repeat-x;
background-size: 100% 0.15rem;
border: 0;
margin: 0;
padding-bottom: 3rem;
padding-top: 3rem;
}
/* Layout */
.container {
width: 94%;
max-width: 65rem;
margin: 0 auto;
position: relative;
}
.main-col {
width: 65%;
float: left;
}
.sidebar {
width: 35%;
float: left;
padding-left: 4rem;
}
/* Demo UI */
* {
box-sizing: border-box;
}
header {
height: 4rem;
padding-right: 2rem;
text-align: right;
margin-bottom: 2rem;
span {
--baselines: 2;
font-family: -apple-system, BlinkMacSystemFont, Aptos, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
margin-right: 1rem;
line-height: calc(var(--baselines) * 1rem);
padding-top: calc(calc(calc(var(--baselines) * 1rem) - 1cap) / 2);
width: 6rem;
display: inline-block;
user-select: none;
transition: 0.3s font-weight;
text-align: center;
&.active {
font-weight: 600;
&:hover {
font-weight: 600;
}
}
&:hover {
cursor: pointer;
font-weight: 500;
}
&:last-child {
margin-right: 0;
}
}
}
// JS not needed for baseline alignment, just for demo
// Toggle grid lines
document.getElementById("toggle").addEventListener( 'click' , () => {
document.documentElement.classList.toggle('show-grid');
});
// Switch font palettes
const palettes = document.querySelectorAll("[id^='palette-']");
palettes.forEach(switcher => {
switcher.addEventListener('click', () => {
document.body.classList.value = ''
document.body.classList.add(switcher.id);
palettes.forEach(switcher => {
switcher.classList.remove('active');
});
switcher.classList.add('active');
});
});
Also see: Tab Triggers