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 class="emptyBlocks"></div>
<article>
<div class="category">REPTILES AND AVES</div>
<h1 class="title">King Cobra</h1>
<p>The king cobra was described and drawn by the Danish naturalist Theodore Edward Cantor in 1836, who gave it the scientific name Hamadryas hannah. Cantor had three specimens from the Sundarbans and one caught in the vicinity of Kolkata. It was subordinated
to the genus Ophiophagus by Albert Günther in 1864.</p>
<p>Ophiophagus hannah belongs to the monotypic genus Ophiophagus in the family Elapidae, while most other cobras are members of the genus Naja. They can be distinguished from other cobras by size and hood. King cobras are generally larger than other cobras,
and the stripe on the neck is a chevron instead of a double or single eye shape that may be seen in most of the other Asian cobras. Moreover, the hood of the king cobra is narrower and longer. A key to identification, clearly visible on the head, is
the presence of a pair of large scales known as occipitals, located at the back of the top of the head. These are behind the usual "nine-plate" arrangement typical of colubrids and elapids, and are unique to the king cobra.</p>
<p class="tallScreenText">The skin of king cobra is dark olive or brown with black bands and white or yellow crossbands. The head is black with two crossbars near the snout and two behind the eyes. Adult king cobras are 3.18 to 4 m (10.4 to 13.1 ft) long. The longest known individual measured 5.85 m (19.2 ft). Its belly is cream or pale yellow. It has 17 to 19 rows of smooth scales. Ventral scales are uniformly oval shaped. Dorsal scales are placed in an oblique arrangement. Males have 235 to 250 ventral scales, while females have 239 to 265. The subcaudal scales are single or paired in each row, numbering 83 to 96 in males and 77 to 98 in females.</p>
<p class="tallScreenText">Juveniles are shiny black with narrow yellow bands (can be mistaken for a banded krait, but readily identified with its expandable hood). The head of a mature snake can be quite massive and bulky in appearance, though like all snakes, it can expand its jaws to swallow large prey items. It has proteroglyph dentition, meaning it has two short, fixed fangs in the front of the mouth, which channel venom into the prey like hypodermic needles. The average lifespan of a wild king cobra is about 20 years.</p>
<div class="footer">
<p>All the text on the articles in this page have been copy-pasted from Wikipedia :)</p>
</div>
</article>
<article>
<div class="category">REPTILES AND AVES</div>
<h1 class="title">Swan</h1>
<p>Swans are birds of the family Anatidae within the genus Cygnus. The swans' close relatives include the geese and ducks. Swans are grouped with the closely related geese in the subfamily Anserinae where they form the tribe Cygnini. Sometimes, they are
considered a distinct subfamily, Cygninae. There are six or seven living (and one extinct) species of swan in the genus Cygnus; in addition, there is another species known as the coscoroba swan, although this species is no longer considered one of the
true swans. Swans usually mate for life, although “divorce” sometimes occurs, particularly following nesting failure, and if a mate dies, the remaining swan will take up with another. The number of eggs in each clutch ranges from three to eight.</p>
<div class="footer">
<p>Fonts used in these articles are <q>Crimson Text</q> and <q>Titan One</q> (for the title).</p>
</div>
</article>
<div class="emptyBlocks"></div>
article {
background-image: linear-gradient(
to bottom,
transparent 50px,
#fdef67 50px,
#fdef67 calc(100% - 50px),
transparent 0
);
margin: auto auto 50px auto;
}
.category,
.title,
.footer {
position: -webkit-sticky;
position: sticky;
height: 50px;
}
.category {
top: 0;
font: 41px/57px "Titan One";
color: #f83d23;
text-shadow: 5px 5px 0 dodgerblue;
}
.title {
top: 0;
font: 50px/60px "Crimson Text";
color: #fdef67;
text-shadow: 2px 2px 0 #f83d23;
background-color: dodgerblue;
margin: 0;
}
.footer {
bottom: 100px;
z-index: -1;
color: white;
text-shadow: 1px 1px black;
background-color: #f83d23;
width: 80%;
margin: 50px auto auto auto;
}
body {
font-family: "Crimson Text";
}
p {
margin: 10px;
}
.emptyBlocks {
background-color: #ccc;
height: 200px;
margin: 40px auto;
}
article,
.emptyBlocks {
width: 80vw;
max-width: 420px;
}
@media (max-width: 420px) {
.category {
font: 24px/72px "Titan One";
text-align: center;
}
.footer {
font-size: 9pt;
}
}
@media (max-height: 946px){
.tallScreenText{
display: none;
}
}
Also see: Tab Triggers