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.
<h1>CSS Chassis</h1>
<hr>
<h1>Heading 1 <h1></h1>
<h2>Heading 2 <h2></h2>
<h3>Heading 3 <h3></h3>
<h4>Heading 4 <h4></h4>
<h5>Heading 5 <h5></h5>
<h6>Heading 6 <h6></h6>
<hr>
<h1>Heading 1 <h1></h1>
<p>Many say exploration is part of our destiny, but it’s actually our duty to future generations and their quest to ensure the survival of the human species.</p>
<h2>Heading 2 <h2></h2>
<p>It suddenly struck me that that tiny pea, pretty and blue, was the Earth. I put up my thumb and shut one eye, and my thumb blotted out the planet Earth. I didn't feel like a giant. I felt very, very small.</p>
<h3>Heading 3 <h3></h3>
<p>The Earth was small, light blue, and so touchingly alone, our home that must be defended like a holy relic. The Earth was absolutely round. I believe I never knew what the word round meant until I saw Earth from space.</p>
<h4>Heading 4 <h4></h4>
<p>To be the first to enter the cosmos, to engage, single-handed, in an unprecedented duel with nature—could one dream of anything more?</p>
<h5>Heading 5 <h5></h5>
<p>What was most significant about the lunar voyage was not that man set foot on the Moon but that they set eye on the earth.</p>
<h6>Heading 6 <h6></h6>
<p>Many say exploration is part of our destiny, but it’s actually our duty to future generations and their quest to ensure the survival of the human species.</p>
<hr>
<h2>Block-level elements</h2>
<p>Here's a paragraph <p> filled with some <a href="http://spaceipsum.com/" target="_blank">Space Ipsum</a>. Never in all their history have men been able truly to conceive of the world as one: a single sphere, a globe, having the qualities of a globe, a round earth in which all the directions eventually meet, in which there is no center because every point, or none, is center — an equal earth which all men occupy as equals. The airman's earth, if free men make it, will be truly round: a globe in practice, not in theory.</p>
<p>There can be no thought of finishing for ‘aiming for the stars.’ Both figuratively and literally, it is a task to occupy the generations. And no matter how much progress one makes, there is always the thrill of just beginning.</p>
<div>Here's a div <div>. A Chinese tale tells of some men sent to harm a young girl who, upon seeing her beauty, become her protectors rather than her violators. That's how I felt seeing the Earth for the first time. I could not help but love and cherish her
</div>
<article>
<h3>This is an article <article> with a paragraph</h3>
<p>We want to explore. We’re curious people. Look back over history, people have put their lives at stake to go out and explore … We believe in what we’re doing. Now it’s time to go.</p>
<p>End of the article.</p>
</article>
<blockquote>Let's light this fire one more time, Mike, and witness this great nation at its best. <blockquote> via <a href="http://spaceipsum.com/" target="_blank">Space Ipsum</a></blockquote>
<p>We choose to go to the moon in this decade and do the other things, not because they are easy, but because they are hard, because that goal will serve to organize and measure the best of our energies and skills, because that challenge is one that we are willing to accept, one we are unwilling to postpone, and one which we intend to win.</p>
<pre>
* {
font-family: 'Comic Sans MS', 'Comic Sans', 'Marker Felt' !important;
}
<pre>
</pre>
<p>Many say exploration is part of our destiny, but it’s actually our duty to future generations and their quest to ensure the survival of the human species.</p>
<address>
<strong>Sherlock Holmes</strong><br>
221B Baker Street<br>
London, United Kingdom <address>
</address>
<hr>
<h2>Lists <li></h2>
<p>The regret on our side is, they used to say years ago, we are reading about you in science class. Now they say, we are reading about you in history class.</p>
<ul>
<li>Unordered list <ul></li>
<li>List element</li>
<li>Across the sea of space, the stars are other suns.</li>
<li>Science cuts two ways, of course; its products can be used for both good and evil. But there's no turning back from science. The early warnings about technological dangers also come from science.</li>
</ul>
<p>It suddenly struck me that that tiny pea, pretty and blue, was the Earth. I put up my thumb and shut one eye, and my thumb blotted out the planet Earth. I didn't feel like a giant. I felt very, very small.</p>
<ol>
<li>Ordered list <ol></li>
<li>List element</li>
<li>The dreams of yesterday are the hopes of today and the reality of tomorrow.</li>
<li>Curious that we spend more time congratulating people who have succeeded than encouraging people who have not.</li>
</ol>
<p>For those who have seen the Earth from space, and for the hundreds and perhaps thousands more who will, the experience most certainly changes your perspective. The things that we share in our world are far more valuable than those which divide us.</p>
<dl>
<dt>Definition term <dt></dt>
<dd>Definition <dd></dd>
<dt>Earth</dt>
<dd>A kick-ass planet.</dd>
<dt>Pluto</dt>
<dd>A kick-ass former planet.</dd>
<dt>Space Ipsum</dt>
<dd>NASA is not about the ‘Adventure of Human Space Exploration’…We won’t be doing it just to get out there in space – we’ll be doing it because the things we learn out there will be making life better for a lot of people who won’t be able to go.</dd>
</dl>
<p>Spaceflights cannot be stopped. This is not the work of any one man or even a group of men. It is a historical process which mankind is carrying out in accordance with the natural laws of human development.</p>
<hr>
<h2>Text-level elements</h2>
<ul>
<li><a href="#">anchor link</a> <a></li>
<li>abbreviation: <abbr title="Syntactically Awesome Stylesheets">SASS</abbr> <abbr></li>
<li><b>bold</b> <b></li>
<li>citation: <cite>A Study in Scarlet</cite> <cite></li>
<li>code: <code><-- @include _hammer --></code> <code></li>
<li>deleted text: <del>Episodes I, II, III</del> <del></li>
<li>definition: The <dfn>definition element</dfn> is the element being defined inline. <dfn></li>
<li><em>emphasis</em> <em></li>
<li><i>italic</i> <i></li>
<li><ins>inserted text</ins> <ins></li>
<li>keyboard input: <kbd>control + space</kbd> <kbd></li>
<li><mark>mark element</mark> <mark></li>
<li>meter: <meter min="200" max="500" value="423">awesomeness</meter> <meter></li>
<li>progress: <progress value="90" max="100">70 %</progress> <progress></li>
<li>quotation (short): <q>You just gotta believe!</q> <q></li>
<li>quotation within a quotation (short): <q>Yo dawg, I heard you like quotes so I put <q>this quote</q> within this quote.</q> <q></li>
<li>strikethough: <s>Lance Armstrong remains steroid-free.</s> <s></li>
<li>sample text: <samp>Error</samp> <samp></li>
<li>small: <small>Hydrogen</small> <small></li>
<li>small within small: <small>Hydrogen <small>Hydrogen</small></small> <small></li>
<li>strong: <strong>The Hammer</strong> <strong></li>
<li>subscript: <sub>Lower</sub> 0<sub>1<sub>2<sub>3</sub></sub></sub> <sub></li>
<li>superscript: I need a good <sup>superman</sup> joke to go here. 0<sup>1<sup>2<sup>3</sup></sup></sup> <sup></li>
<li>time: <time datetime="1985-12-09 19:00">Dec 9</time> <time></li>
<li>underline: Never underline <u>anything</u>. <u></li>
<li>variable: <var>cat</var> + <var>dog</var> = <var>catdog</var> <var></li>
</ul>
<hr>
@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700,400italic,700italic);
// Em conversion function
@function em($value, $context: $body) {
@return ($value / $context * 1em);
}
// Uses perfect fifths modular scale
// Primary: 20
// Secondary: 16
// Multiplier: 1.5
// http://modularscale.com/scale/?px1=20&px2=16&ra1=1.5&ra2=0
// Easier way to see/edit values
$body: 20px;
$h1: 67px; // 54 works nicely, as well
$h2: 36px;
$h3: 30px;
$h4: 24px;
$h5: 20px;
$h6: 16px;
body {
max-width: 700px;
margin: 3em auto;
padding: 0 1em;
font: 400 #{$body}/1.5 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
@media ( max-width: 800px ) {
font-size: 16px;
}
@media ( max-width: 500px ) {
font-size: 14px;
}
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: 600;
line-height: 1;
&:after {
color: #ccc;
font-size: 12px;
font-weight: 400;
}
}
h1 {
font-size: em($h1);
font-weight: 700;
&:after {
content: ' #{$h1}'
}
}
h2 {
font-size: em($h2);
&:after {
content: ' #{$h2}'
}
}
h3 {
font-size: em($h3);
&:after {
content: ' #{$h3}'
}
}
h4 {
font-size: em($h4);
&:after {
content: ' #{$h4}'
}
}
h5 {
font-size: em($h5);
&:after {
content: ' #{$h5}'
}
}
h6 {
font-size: em($h6);
text-transform: uppercase;
&:after {
content: ' #{$h6}'
}
}
// Shows body font size;
p {
&:after {
content: ' #{$body}';
color: #ccc;
font-size: 12px;
}
}
// Block-level elements
hr {
border: 0;
border-bottom: 1px solid #999;
}
blockquote {
margin: 0;
padding-left: 1em;
position: relative;
border-left: 4px solid #eee;
font-style: italic;
}
pre {
padding: 16px 20px;
background: #f7f7f7;
font: normal 12px/1.4 Consolas, "Andale Mono", Menlo, Courier, monospace;
}
// Lists
li {}
dt {
font-weight: 600;
}
dd {
margin: 0;
}
// Text-level elements
a {
color: inherit;
text-decoration: none;
// Medium text single-pixel underline hack
background-image: linear-gradient(to bottom, rgba(0,0,0,0) 75%, #000 50%);
background-repeat: repeat-x;
background-size: 2px 2px;
background-position: 0 1.056em; // ~19/18
@media not all, only screen and (min-resolution: 2dppx), only screen and (-webkit-min-device-pixel-ratio: 2) {
background-image: linear-gradient(to bottom, rgba(0,0,0,0) 75%, #000 75%);
background-repeat: repeat-x;
}
}
b,
strong {
font-weight: 700;
}
Also see: Tab Triggers