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.
<ul role="list">
<li>
<a href="https://front-end.social/@oddbird">
<svg width="24" height="24" version="2.0"><use href="#mastodon"/></svg>
<icon-text>@oddbird@front-end.social</icon-text>
</a>
</li>
<li>
<a href="https://bsky.app/profile/oddbird.dev">
<svg width="24" height="24" version="2.0"><use href="#bluesky"/></svg>
@oddbird.dev
</a>
</li>
</ul>
<svg version="2.0" hidden>
<defs>
<symbol id="mastodon" viewBox="0 0 24 24" fill="currentColor"><path d="M21.2595 13.9898C20.9852 15.4006 18.8033 16.9446 16.2974 17.2439C14.9907 17.3998 13.7041 17.5431 12.3321 17.4802C10.0885 17.3774 8.31809 16.9446 8.31809 16.9446C8.31809 17.163 8.33156 17.371 8.3585 17.5655C8.65019 19.7797 10.5541 19.9124 12.3576 19.9742C14.1779 20.0365 15.7987 19.5254 15.7987 19.5254L15.8735 21.1711C15.8735 21.1711 14.6003 21.8548 12.3321 21.9805C11.0814 22.0493 9.52849 21.9491 7.71973 21.4703C3.79684 20.432 3.12219 16.2504 3.01896 12.0074C2.98749 10.7477 3.00689 9.55981 3.00689 8.56632C3.00689 4.22771 5.84955 2.95599 5.84955 2.95599C7.2829 2.29772 9.74238 2.0209 12.2993 2H12.3621C14.919 2.0209 17.3801 2.29772 18.8133 2.95599C18.8133 2.95599 21.6559 4.22771 21.6559 8.56632C21.6559 8.56632 21.6916 11.7674 21.2595 13.9898ZM18.3029 8.9029C18.3029 7.82924 18.0295 6.97604 17.4805 6.34482C16.9142 5.71359 16.1726 5.39001 15.2522 5.39001C14.187 5.39001 13.3805 5.79937 12.8473 6.61819L12.3288 7.48723L11.8104 6.61819C11.2771 5.79937 10.4706 5.39001 9.40554 5.39001C8.485 5.39001 7.74344 5.71359 7.17719 6.34482C6.62807 6.97604 6.3547 7.82924 6.3547 8.9029V14.1562H8.43597V9.05731C8.43597 7.98246 8.88822 7.4369 9.79281 7.4369C10.793 7.4369 11.2944 8.08408 11.2944 9.36376V12.1547H13.3634V9.36376C13.3634 8.08408 13.8646 7.4369 14.8648 7.4369C15.7694 7.4369 16.2216 7.98246 16.2216 9.05731V14.1562H18.3029V8.9029Z"></path></symbol>
<symbol id="bluesky" viewBox="0 0 24 24" fill="currentColor"><path d="M12 11.3884C11.0942 9.62673 8.62833 6.34423 6.335 4.7259C4.13833 3.17506 3.30083 3.4434 2.75167 3.69256C2.11583 3.9784 2 4.95506 2 5.52839C2 6.10339 2.315 10.2367 2.52 10.9276C3.19917 13.2076 5.61417 13.9776 7.83917 13.7309C4.57917 14.2142 1.68333 15.4017 5.48083 19.6292C9.65833 23.9542 11.2058 18.7017 12 16.0392C12.7942 18.7017 13.7083 23.7651 18.4442 19.6292C22 16.0392 19.4208 14.2142 16.1608 13.7309C18.3858 13.9784 20.8008 13.2076 21.48 10.9276C21.685 10.2376 22 6.10256 22 5.52923C22 4.95423 21.8842 3.97839 21.2483 3.6909C20.6992 3.44256 19.8617 3.17423 17.665 4.72423C15.3717 6.34506 12.9058 9.62756 12 11.3884Z"></path></symbol>
</defs>
</svg>
a:has(icon-text) {
text-decoration: none;
}
icon-text {
text-decoration: underline;
}
svg {
vertical-align: middle;
}
@layer reset, props, base;
@layer base {
html {
font-family: var(--serif);
color-scheme: light dark;
}
body {
font-size: var(--text-normal);
display: grid;
min-block-size: 100%;
padding: var(--gap);
place-content: center;
}
[role=list] {
list-style: none;
padding-inline-start: unset;
}
[demo-style] {
border-block: thin dashed;
display: block;
font-family: monospace;
margin-block: 0.5lh;
overflow: auto;
padding-block: 0.5lh;
white-space: pre;
}
code:not(pre *) {
background: linear-gradient(
-80deg,
transparent 0.5ch,
var(--pink-bg) 0.5ch calc(100% - 0.5ch),
transparent calc(100% - 0.5ch)
) no-repeat 0 1ex;
text-shadow: 2px 2px 0 Canvas;
}
}
@layer props {
html {
--pink-dark-: #B6236C;
--pink-light-: #FE84B4;
--blue-dark-: #205769;
--blue-light-: #8EC6DA;
--pink: light-dark(var(--pink-dark-), var(--pink-light-));
--pink-bg: color-mix(in oklab,
light-dark(var(--pink-light-), var(--pink-dark-)),
Canvas
);
--blue: light-dark(var(--blue-dark-), var(--blue-light-));
--blue-bg: color-mix(in oklab,
light-dark(var(--blue-light-), var(--blue-dark-)),
Canvas
);
@supports not (fill: color-mix(in hsl, light-dark(red, red), red)) {
--pink: var(--pink-dark-);
--blue: var(--blue-dark-);
--pink-bg: var(--pink-light-);
--blue-bg: var(--blue-light-);
@media (prefers-color-scheme: dark) {
--pink: var(--pink-light-);
--blue: var(--blue-light-);
--pink-bg: var(--pink-dark-);
--blue-bg: var(--blue-dark-);
}
}
/* from https://modernfontstacks.com/ */
/* old style, industrial, slab */
--serif: 'Iowan Old Style', 'Palatino Linotype', 'URW Palladio L', P052, serif;
--sans: Bahnschrift, 'DIN Alternate', 'Franklin Gothic Medium', 'Nimbus Sans Narrow', sans-serif-condensed, sans-serif;
--slab: Rockwell, 'Rockwell Nova', 'Roboto Slab', 'DejaVu Serif', 'Sitka Small', serif;
}
body {
--text-small: clamp(0.938rem, 0.824rem + 0.568cqi, 1.25rem);
--text-normal: clamp(1.25rem, 1.023rem + 1.136cqi, 1.875rem);
--text-large: clamp(1.35rem, 0.818rem + 2.659cqi, 2.813rem);
--text-xlarge: clamp(1.7rem, 0.784rem + 4.58cqi, 4.219rem);
--gap: clamp(2cqi, 0.5lh, 5cqi);
}
}
@layer reset {
* { box-sizing: border-box; }
html { block-size: 100%; }
body { margin: unset; }
h1, h2, h3, h4, h5, h6 {
text-wrap: balance;
}
p, li {
text-wrap: pretty;
}
picture { display: contents; }
img { display: block; }
img,
svg {
max-inline-size: 100%;
block-size: auto;
}
input,
button,
textarea,
select {
font: inherit;
}
[hidden] {
display: none !important;
}
}
Also see: Tab Triggers