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.
<button type="button">
<svg width="100%" height="100%" viewBox="0 0 300 300" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" pointer-events="none">
<title>Save</title>
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M75.75,272.702381 L223.25,272.702381 L223.25,198.952381 L75.75,198.952381 L75.75,272.702381 Z M247.833333,272.702381 L272.416667,272.702381 L272.416667,100.619048 C272.416667,98.8265039 271.776482,96.3617933 270.496094,93.2248419 C269.215705,90.0878904 267.935336,87.8792537 266.654948,86.5988653 L212.686849,32.6307664 C211.406461,31.350378 209.229833,30.0700089 206.156901,28.7896205 C203.083969,27.5092322 200.587249,26.8690476 198.666667,26.8690476 L198.666667,106.764881 C198.666667,111.886434 196.87415,116.239689 193.289063,119.824777 C189.703975,123.409864 185.35072,125.202381 180.229167,125.202381 L69.6041667,125.202381 C64.4826133,125.202381 60.1293582,123.409864 56.5442708,119.824777 C52.9591835,116.239689 51.1666667,111.886434 51.1666667,106.764881 L51.1666667,26.8690476 L26.5833333,26.8690476 L26.5833333,272.702381 L51.1666667,272.702381 L51.1666667,192.806548 C51.1666667,187.684994 52.9591835,183.331739 56.5442708,179.746652 C60.1293582,176.161564 64.4826133,174.369048 69.6041667,174.369048 L229.395833,174.369048 C234.517387,174.369048 238.870642,176.161564 242.455729,179.746652 C246.040817,183.331739 247.833333,187.684994 247.833333,192.806548 L247.833333,272.702381 Z M174.083333,94.4732143 L174.083333,33.014881 C174.083333,31.3503761 173.475158,29.9099608 172.258789,28.6935919 C171.04242,27.477223 169.602005,26.8690476 167.9375,26.8690476 L131.0625,26.8690476 C129.397995,26.8690476 127.95758,27.477223 126.741211,28.6935919 C125.524842,29.9099608 124.916667,31.3503761 124.916667,33.014881 L124.916667,94.4732143 C124.916667,96.1377191 125.524842,97.5781344 126.741211,98.7945033 C127.95758,100.010872 129.397995,100.619048 131.0625,100.619048 L167.9375,100.619048 C169.602005,100.619048 171.04242,100.010872 172.258789,98.7945033 C173.475158,97.5781344 174.083333,96.1377191 174.083333,94.4732143 Z M297,100.619048 L297,278.848214 C297,283.969768 295.207483,288.323023 291.622396,291.90811 C288.037308,295.493197 283.684053,297.285714 278.5625,297.285714 L20.4375,297.285714 C15.3159466,297.285714 10.9626915,295.493197 7.37760417,291.90811 C3.7925168,288.323023 2,283.969768 2,278.848214 L2,20.7232143 C2,15.6016609 3.7925168,11.2484058 7.37760417,7.66331845 C10.9626915,4.07823108 15.3159466,2.28571429 20.4375,2.28571429 L198.666667,2.28571429 C203.78822,2.28571429 209.421844,3.56608343 215.567708,6.12686012 C221.713572,8.68763681 226.578975,11.7605227 230.164062,15.3456101 L283.940104,69.1216518 C287.525192,72.7067392 290.598077,77.5721419 293.158854,83.718006 C295.719631,89.86387 297,95.4974942 297,100.619048 Z" id="save-icon" fill="#000000"></path>
</g>
</svg></button>
button {
display: flex;
padding: .25em;
width: 10rem;
height: 10rem;
margin: 2rem auto;
}
document.querySelector('button').addEventListener('click', (event) => {
alert(`${event.target.nodeName.toUpperCase()} element`);
})
Also see: Tab Triggers