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.
- arr = Array.from(Array(100).keys())
mixin svg
svg(width="24" height="24" viewBox="0 0 24 24" fill="#000")
path(d="M9.29289 18.7071C8.90237 18.3166 8.90237 17.6834 9.29289 17.2929L14.5858 12L9.29289 6.70711C8.90237 6.31658 8.90237 5.68342 9.29289 5.29289C9.68342 4.90237 10.3166 4.90237 10.7071 5.29289L16.7071 11.2929C17.0976 11.6834 17.0976 12.3166 16.7071 12.7071L10.7071 18.7071C10.3166 19.0976 9.68342 19.0976 9.29289 18.7071Z")
header
.holder
h1#title My longer view title
main
p.intro Currently this demo only works in Chrome Canary.
ul
each val in arr
li
div
h2 Item title
p My item meta
+svg
// Vars
$header-height: 90px;
$header-padding: 15px;
html, body {
margin: 0;
padding: 0;
}
main {
padding: 90px 0 20px;
height: calc(100% - $header-height);
}
.intro {
background: #FFC;
padding: 15px;
text-align: center;
}
html {
scroll-timeline: --title-scroller block;
}
body {
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
main li {
padding: 15px;
position: relative;
z-index: -1;
display: flex;
justify-content: space-between;
align-items: center;
&:after {
content: ' ';
border-bottom: 1px solid #DDD;
position: absolute;
left: 15px;
bottom: 0;
width: 100%;
}
}
li svg {
opacity: .33;
}
li p {
color: gray;
}
main h2 {
font-weight: 600;
margin-bottom: 4px;
}
header {
padding: $header-padding;
background: #FFF;
height: $header-height - ($header-padding*2);
border-bottom: 1px solid transparent;
position: fixed;
left: 0; right: 0;
animation: bar auto linear;
animation-timeline: --title-scroller;
animation-range: 0 100px;
animation-fill-mode: forwards;
}
header .holder {
position: relative;
width: 100%;
}
header h1 {
font-weight: 600;
position: absolute;
left: 0;
right: 0;
margin: 0;
padding: 0;
animation: grow auto linear;
animation-timeline: --title-scroller;
animation-range: 0 100px;
animation-fill-mode: forwards;
font-size: 46px;
}
@keyframes grow {
to {
left: 50%;
translate: -25%;
font-size: 20px;
}
}
@keyframes bar {
to {
height: 24px;
border-bottom-color: #DDD;
}
}
Also see: Tab Triggers