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 class="List">
<li class="Card">
<img class="Card-Image" src="https://placekitten.com/200/200" alt="Picture of Griffith">
<div class="Card-Content">
<p class="Card-Title"><a class="Card-Primary-Action" href="/cat/griffith">Griffith</a>
</p>
<p class="Card-Meta">13 year old bluepoint Persian cat</p>
</div>
<button type="button" class="Card-Secondary-Action">Details</button>
</li>
<li class="Card">
<img class="Card-Image" src="https://placekitten.com/200/200" alt="Picture of Lilith">
<div class="Card-Content">
<p class="Card-Title"><a class="Card-Primary-Action" href="/cat/lilith">Lilith</a></p>
<p class="Card-Meta">10 year old grey British Shorthair cat</p>
</div>
<button type="button" class="Card-Secondary-Action">Details</button>
</li>
<li class="Card">
<img class="Card-Image" src="https://placekitten.com/200/200" alt="Picture of MacBeth">
<div class="Card-Content">
<p class="Card-Title"><a class="Card-Primary-Action" href="/cat/macbeth">MacBeth</a></p>
<p class="Card-Meta">5 year old brown European cat</p>
</div>
<button type="button" class="Card-Secondary-Action">Details</button>
</li>
</ul>
/**
* @author Kitty Giraudel
* https://twitter.com/KittyGiraudel
* https://www.linkedin.com/in/kitty-giraudel/
*/
body {
font-family: sans-serif;
font-size: 125%;
margin: 2em;
}
/**
* 1. Reset the default styles from a list.
*/
.List {
list-style: none; /* 1 */
padding-left: 0; /* 1 */
margin: 0; /* 1 */
}
/**
* 1. Make each item look like a card.
* 2. Provide position context for the button pseudo-element.
* 3. Clean the image’s float.
* 4. Enable flex layout for left/right items.
*/
.Card {
border: 1px solid rgb(100 0 0 / 0.2); /* 1 */
box-shadow: 0 0 0.5em -0.15em rgb(50 0 0 / 0.15); /* 1 */
border-radius: 0.4em; /* 1 */
padding: 1em; /* 1 */
margin: 1em 0;
position: relative; /* 2 */
overflow: hidden; /* 3 */
display: flex; /* 4 */
align-items: flex-start; /* 4 */
gap: 1em; /* 4 */
}
/**
* 1. Reset the default styles from a heading (in case it is a
* `<hx>` element).
*/
.Card-Title {
font-size: 100%; /* 1 */
margin-top: 0; /* 1 */
margin-bottom: 0.5em; /* 1 */
font-weight: bold;
}
/**
* 1. Reset the default styles from a link.
*/
.Card-Primary-Action {
color: deeppink;
text-decoration: none; /* 1 */
}
/**
* 1. Use a pseudo-element to expand the hitbox of the link over
* the whole card.
* 2. Expand the hitbox over the whole card.
* 3. Show that the card is interactive.
*/
.Card-Primary-Action::before {
content: ""; /* 1 */
position: absolute; /* 2 */
top: 0; /* 2 */
left: 0; /* 2 */
right: 0; /* 2 */
bottom: 0; /* 2 */
border: 2px solid transparent; /* 3 */
cursor: pointer; /* 3 */
border-radius: 0.3em;
transition: border-color 200ms;
}
/**
* 1. Hide the default focus outline as it’s recreated with a border.
*/
.Card-Primary-Action:focus {
outline: none; /* 1 */
}
/**
* 1. Display interactivity on hover/focus by highlighting the border.
*/
.Card-Primary-Action:hover::before,
.Card-Primary-Action:focus::before {
border-color: hotpink; /* 1 */
}
.Card-Meta {
margin: 0;
}
.Card-Image {
border-radius: 50%;
max-width: 2.75em;
}
/**
* 1. Push the secondary action to the right of the card.
* 2. Place secondary action on top of the card.
*/
.Card-Secondary-Action {
margin-left: auto; /* 1 */
z-index: 2; /* 2 */
position: relative; /* 2 */
cursor: pointer;
}
/**
* 1. Make the dialog container, and its child overlay spread across
* the entire window.
*/
.dialog-container,
.dialog-overlay {
position: fixed; /* 1 */
top: 0; /* 1 */
right: 0; /* 1 */
bottom: 0; /* 1 */
left: 0; /* 1 */
}
/**
* 1. Make sure the dialog container and all its descendants sits on
* top of the rest of the page.
* 2. Make the dialog container a flex container to easily center the
* dialog.
*/
.dialog-container {
z-index: 2; /* 1 */
display: flex; /* 2 */
}
.dialog-content {
padding: 1em;
}
/**
* 1. Make sure the dialog container and all its descendants are not
* visible and not focusable when it is hidden.
*/
.dialog-container[aria-hidden="true"] {
display: none; /* 1 */
}
/**
* 1. Make the overlay look like an overlay.
*/
.dialog-overlay {
background-color: rgba(43, 46, 56, 0.9); /* 1 */
}
/**
* 1. Vertically and horizontally center the dialog in the page.
* 2. Make sure the dialog sits on top of the overlay.
* 3. Make sure the dialog has an opaque background.
*/
.dialog-content {
margin: auto; /* 1 */
z-index: 2; /* 2 */
position: relative; /* 2 */
background-color: white; /* 3 */
}
.dialog-title {
margin-top: 0;
}
.sr-only {
border: 0 !important;
clip: rect(1px, 1px, 1px, 1px) !important;
-webkit-clip-path: inset(50%) !important;
clip-path: inset(50%) !important;
height: 1px !important;
overflow: hidden !important;
margin: -1px !important;
padding: 0 !important;
position: absolute !important;
width: 1px !important;
white-space: nowrap !important;
}
Also see: Tab Triggers