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.
<main mv-app="boxmodel" mv-bar="none" mv-storage="local">
<article>
<h1 style="letter-spacing:[ls]em; word-spacing:[ws]em">
Interactive Typesetting</h1>
<h2>Use the sliders to visualise how the tools of traditional typography (font-sizes, leading (line-height), tracking (letter-spacing), and spaces (word-spacing) are applied with CSS coding. NOTE: It’s common to use simple “unitless” values for setting line-height — and rely on the CSS 'em' values to fine-tune letter and word spacing based on the size of the font itself.</h2>
<section>
<p style="font-size:[fz]px; line-height:[lh]; letter-spacing:[ls]em; word-spacing:[ws]em">TYPESETTING IS THE PRINTER’S ART of composing individual letters of a typeface to create an appealing and readable presentation of the text on a page (or - in our case - the screen). Much of the function and jargon of CSS typesetting properties derives from the traditions of movable type and letterpress printing.</p>
<p style="font-size:[fz]px; line-height:[lh]; letter-spacing:[ls]em; word-spacing:[ws]em"><strong>The Crystal Goblet or Printing Should be Invisible</strong> from Beatrice Warde,<em>The Crystal Goblet, Sixteen Essays on Typography, Cleveland, 1956</em></p>
<p style="font-size:[fz]px; line-height:[lh]; letter-spacing:[ls]em; word-spacing:[ws]em">Imagine that you have before you a flagon of wine. You may choose your own favorite vintage for this imaginary demonstration, so that it be a deep shimmering crimson in colour. You have two goblets before you. One is of solid gold, wrought in the most exquisite patterns. The other is of crystal-clear glass, thin as a bubble, and as transparent. Pour and drink; and according to your choice of goblet, I shall know whether or not you are a connoisseur of wine. For if you have no feelings about wine one way or the other, you will want the sensation of drinking the stuff out of a vessel that may have cost thousands of pounds; but if you are a member of that vanishing tribe, the amateurs of fine vintages, you will choose the crystal, because everything about it is calculated to reveal rather than to hide the beautiful thing which it was meant to contain.</p>
<p style="font-size:[fz]px; line-height:[lh]; letter-spacing:[ls]em; word-spacing:[ws]em">Bear with me in this long-winded and fragrant metaphor; for you will find that almost all the virtues of the perfect wine-glass have a parallel in typography. There is the long, thin stem that obviates fingerprints on the bowl. Why? Because no cloud must come between your eyes and the fiery heart of the liquid. Are not the margins on book pages similarly meant to obviate the necessity of fingering the type-page? Again: the glass is colourless or at the most only faintly tinged in the bowl, because the connoisseur judges wine partly by its colour and is impatient of anything that alters it. There are a thousand mannerisms in typography that are as impudent and arbitrary as putting port in tumblers of red or green glass! When a goblet has a base that looks too small for security, it does not matter how cleverly it is weighted; you feel nervous lest it should tip over. There are ways of setting lines of type which may work well enough, and yet keep the reader subconsciously worried by the fear of 'doubling' lines, reading three words as one, and so forth."</p>
</section>
</article>
<pre>
<div>
*{ font-size:<span>[fz]px</span>;<input class="indent" type="range" property="fz" value="24" min="10" max="72"/>
</div>
<div>
line-height:<span>[lh]</span>;<input class="indent" type="range" property="lh" value="1.6" min="0.0" max="3.0" step="0.1"/>
</div>
<div>
letter-spacing:<span>[ls]em</span>;
<input class="indent" type="range" property="ls" value="0.03" min="-1.0" max="1.0" step="0.01"/>
</div>
<div>
word-spacing:<span>[ws]em</span>;
<input class="indent" type="range" property="ws" value="0.04" min="-1" max="2" step="0.01"/>
</div>
<div>
}
</div>
</pre>
</main>
@import url('https://fonts.googleapis.com/css2?family=Bungee&family=Noto+Serif:ital,wght@0,400;0,700;1,400;1,700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Alfa+Slab+One&family=EB+Garamond:ital,wght@0,400;0,600;1,400;1,600&display=swap');
body {
font-family: "EB Garamond";
font-weight: 400;
font-size: 16px;
}
section{
outline: 2px dotted blue;
padding: 20px;
width: 90%;
margin:auto;
margin-top: 20px;
}
p{
margin-bottom: 1em;
}
/* em,strong {
outline: 2px dotted lime;
overflow: hidden;
}
*/
em {
font-style: italic;
}
strong{
font-weight: 700;
}
ul {
border: 2px dotted blue;
}
h1{
font-family: "Bungee";
font-size: 12vw;
border-bottom: 12px double black;
line-height: 0.8;
text-align: center;
color:rgba(0,0,0,.6);
margin: 30px 0;
padding-bottom: 30px;
}
h2 {
font-family: "Noto Serif";
font-size: 110%;
font-weight: 200;
font-style: italic;
background-color: tomato;
color: white;
line-height: 1.3;
border-radius:20px;
padding: 2em;
margin: 10px;
}
a {
color: tomato;
font-weight: 700;
}
pre {
min-width:300px;
box-sizing: border-box;
position: fixed;
bottom: 50px;
right: 50px;
/* left: 50%;
transform:translateX(-50%); */
font-family: courier;
font-size: 20px;
border-radius: 20px;
padding: 10px 30px 20px 10px;
background-color: #212121;
line-height: .5;
color: limegreen;
display: flex;
flex-direction: column;
}
pre span {
color: tomato;
}
input{display: block; margin-left: 3ch; width: 250px;}
.indent{margin-left: 6ch;}
input[type=range]::-webkit-slider-runnable-track {
cursor: pointer;
background: tomato;
border: 0.2px solid #010101;
margin-top:1em;
}
Also see: Tab Triggers