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.
<div>
<p>
<label>
Font size:
<input id="numFontSize" type="range" min="5" max="30" />
</label>
<output id="outputFontSize"></output>
</p>
<p>
<label>
Columns:
<input id="numColumns" type="range" min="1" max="10" />
</label>
<output id="outputColumns"></output>
</p>
<p>
<label>
Widows:
<input id="numWidows" type="range" min="1" max="10" />
</label>
<output id="outputWidows"></output>
</p>
<p>
<label>
Orphans:
<input id="numOrphans" type="range" min="1" max="10" />
</label>
<output id="outputOrphans"></output>
</p>
</div>
<div class="frame">
<p>Hello World!</p>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Consectetur voluptatum eum nulla. Corrupti aut, repellendus sunt quia, eligendi iure harum incidunt optio exercitationem rem quis maxime facilis alias dolorem illo?
Fuga amet facere dolores asperiores minima non voluptatem laudantium exercitationem consequuntur aspernatur reiciendis molestiae in animi, repudiandae optio. Error veniam harum mollitia similique eligendi dolorem minus neque ab accusantium numquam.
</p>
<p>
Hic tenetur magnam facere iure explicabo architecto eius non voluptatibus consequatur? Saepe velit nihil exercitationem ducimus dolore voluptas aliquid! Vitae libero omnis asperiores voluptate beatae vero, cumque at modi pariatur.
Dolore voluptate commodi quas ut nemo molestiae excepturi repellendus alias facilis ipsa cupiditate distinctio corporis nostrum tempora repellat unde veniam numquam molestias perspiciatis, sed inventore sint quidem! Dolore, veritatis fugiat!
Repellendus nihil laboriosam odio tempore blanditiis iure fuga? Assumenda, voluptas nulla. Sapiente accusamus odio neque qui consequatur dolorum veritatis amet rerum dignissimos ab, reprehenderit, vel numquam laudantium. Pariatur, possimus rem!
</p>
<p>
Dicta nam, soluta rem et pariatur reprehenderit placeat expedita earum perferendis mollitia deserunt ipsum, voluptatem impedit beatae vel ratione ipsa temporibus accusantium. Magni beatae nesciunt totam error numquam at eos!
Eligendi, quos ducimus maxime autem necessitatibus blanditiis? Maiores suscipit aspernatur expedita, repellat beatae aut reiciendis eum illum blanditiis sit deleniti eos ea rerum? Recusandae beatae quia obcaecati, dignissimos asperiores consectetur!
Ea nostrum dolorum quibusdam saepe optio totam ex provident, ab vel molestias obcaecati autem, iure cum recusandae ad architecto labore placeat voluptatum repudiandae porro, aut fuga pariatur reiciendis? Beatae, perspiciatis.
Esse vero enim, dolore itaque autem amet. Consequatur sapiente ipsam voluptates animi porro deleniti velit, incidunt harum repellendus ducimus, earum recusandae, eum in esse nisi sed reiciendis eligendi placeat laboriosam!
Asperiores minus tenetur provident et accusantium. Molestias blanditiis magni ipsa porro aliquid asperiores consequuntur animi optio? At cum, obcaecati, libero quibusdam velit dolorem praesentium consectetur, debitis sit qui laudantium non!
</p>
<p>
Pariatur facere aliquid quidem minus debitis itaque architecto magnam saepe inventore fuga nisi, quaerat expedita aliquam veritatis illo ipsa tempore incidunt quis consectetur aut dignissimos esse eveniet dolore. Debitis, nostrum?
</p>
</div>
body {
--font-size: 10px;
--columns: 5;
--widows: 2;
--orphans: 2;
}
.frame {
border: 1px solid lightgray;
columns: var(--columns);
font-size: var(--font-size);
orphans: var(--orphans);
widows: var(--widows);
p {
background-color: lightgray;
line-height: 1.2;
margin: 0;
text-indent: 1rem;
}
p + p {
margin-top: 1rem;
}
}
let fontSize = 10;
let columns = 5;
let widows = 2;
let orphans = 2;
const elNumFontSize = document.querySelector('#numFontSize');
const elOutputFontSize = document.querySelector('#outputFontSize');
const elNumColumns = document.querySelector('#numColumns');
const elOutputColumns = document.querySelector('#outputColumns');
const elNumWidows = document.querySelector('#numWidows');
const elOutputWidows = document.querySelector('#outputWidows');
const elNumOrphans = document.querySelector('#numOrphans');
const elOutputOrphans = document.querySelector('#outputOrphans');
elNumFontSize.addEventListener('input', () => {
fontSize = elNumFontSize.valueAsNumber;
render();
});
elNumColumns.addEventListener('input', () => {
columns = elNumColumns.valueAsNumber;
render();
});
elNumWidows.addEventListener('input', () => {
widows = elNumWidows.valueAsNumber;
render();
});
elNumOrphans.addEventListener('input', () => {
orphans = elNumOrphans.valueAsNumber;
render();
});
function render() {
elNumFontSize.value = fontSize;
elOutputFontSize.textContent = `${fontSize}px`;
document.body.style.setProperty('--font-size', `${fontSize}px`);
elNumColumns.value = columns;
elOutputColumns.textContent = columns;
document.body.style.setProperty('--columns', columns);
elNumWidows.value = widows;
elOutputWidows.textContent = widows;
document.body.style.setProperty('--widows', widows);
elNumOrphans.value = orphans;
elOutputOrphans.textContent = orphans;
document.body.style.setProperty('--orphans', orphans);
}
render();
Also see: Tab Triggers