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 class="title">Extracts from "Our Cats, by Harrison Weir"</h1>
<article class="wrapper">
<nav class="mainnav">
<ul>
<li><a href="">Introductory</a></li>
<li><a href="">The First Cat Show</a></li>
<li><a href="">Habits</a></li>
<li><a href="">Trained Cats</a></li>
<li><a href="">Usefulness of Cats</a></li>
</ul>
</nav>
<h2 class="subhead">Usefulness of cats</h2>
<div class="content">
<p>In our urban and suburban houses what should we do without cats? In our sitting or bedrooms, our libraries, in our kitchens and storerooms, our farms, barns, and rickyards, in our docks, our granaries, our ships, and our wharves, in our corn markets, meat markets, and other places too numerous to mention, how useful they are! In our ships, however, the rats oft set them at defiance; still they are of great service.</p>
<p>How wonderfully patient is the cat when watching for rats or mice, awaiting their egress from their place of refuge or that which is their home! How well Shakespeare in Pericles, Act iii., describes this keen attention of the cat to its natural pursuit!</p>
<blockquote><p>The cat, with eyne of burning coal, Now crouches from (before) the mouse's hole.</p></blockquote>
<p>A slight rustle, and the fugitive comes forth; a quick, sharp, resolute motion, and the cat has proved its usefulness. Let any one have a plague of rats and mice, as I once had, and let them be delivered therefrom by cats, as I was, and they will have a lasting and kind regard for them.</p>
<p>A friend not long since informed me that a cat at Stone's Distillery was seen to catch two rats at one time, a fore foot on each. All the cats kept at this establishment, and there are several, are of the red tabby colour, and therefore most likely all males.</p>
<p>I am credibly informed of a still more extraordinary feat of a cat in catching mice, that of a red tabby cat which on being taken into a granary at Sevenoaks where there were a number of mice, dashed in among a retreating group, and secured four, one with each paw and two in her mouth.</p>
<p>At the office of The Morning Advertiser, I am informed by my old friend Mr. Charles Williams, they boast of a race of cats bred there for nearly half a century. In colour these are mostly tortoiseshell, and some are very handsome.</p>
<p>The Government, mindful also of their utility, pay certain sums, which are regularly passed through the accounts quarterly, for the purpose of providing and keeping cats in our public offices, dockyards, stores, shipping, etc., thereby proving, if proof were wanting, their acknowledged worth.</p>
<p>In Vienna four cats are employed by the town magistrates to catch mice on the premises of the municipality. A regular allowance is voted for their keep, and, after a limited period of active service, they are placed on the "retired list," with a comfortable pension.</p>
<p>There are also a number of cats in the service of the United States Post Office. These cats are distributed over the different offices to protect the bags from being eaten by rats and mice, and the cost of providing for them is duly inscribed in the accounts. When a birth takes place, the local postmaster informs the district superintendent of the fact, and obtains an addition to his rations.
</p>
</div>
<blockquote class="quote">
<p>Let any one have a plague of rats and mice, as I once had, and let them be delivered therefrom by cats, as I was, and they will have a lasting and kind regard for them.</p>
</blockquote>
</article>
body {
margin: 0;
padding: 20px;
color: #333;
background-color: #efefef;
font: 87.5%/1.4 HelveticaNeue, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
img {
max-width: 100%;
display: block;
height: auto;
}
figure {
margin: 0;
padding: 0;
}
figcaption {
font-family: "Georgia","Times New Roman",serif;
text-align: center;
padding: 0.5em 0 1em 0;
}
h1, h2, h3, h4, h5, h6 {
font-family: "Georgia","Times New Roman",serif;
font-weight: normal;
padding: 0;
margin: 0;
}
h1 {
font-size: 328.571%;
margin-bottom: 0.2em;
}
h1.title {
text-align: center;
}
h2 {
font-size: 250%;
margin-bottom: 0.2em;
}
h3 {
font-size: 150%;
margin-bottom: 0.2em;
}
p {
margin:0;
padding: 0 0 1em 0;
}
.wrapper {
background-color: #fff;
color: #444;
padding: 1em 3% 1em 3%;
margin: 0 auto 1em auto;
}
.mainnav ul {
margin: 0;
padding: 0;
list-style: none;
font-size: 120%;
}
.mainnav a:link, .mainnav a:visited {
text-decoration: none;
color: #444;
}
.quote {
font: 150%/1.4 "Georgia","Times New Roman",serif;
padding: 0;
margin: 0;
}
@media only screen and (min-width: 460px) {
.wrapper {
display: grid;
width: 90%;
grid-template-columns: auto ;
grid-template-rows: auto ;
}
.mainnav {
grid-row: 1 / 2;
}
.subhead {
grid-row: 2 / 3;
}
.quote {
grid-row: 3 / 4;
}
.content {
grid-row: 4 / 5;
}
}
@media only screen and (min-width: 700px) {
.wrapper {
grid-template-columns: 20% 5% auto ;
grid-template-rows: auto ;
}
.mainnav {
grid-column: 1 / 2;
grid-row: 2 / 3;
}
.subhead {
grid-row: 1 / 2;
grid-column: 3 / 4;
}
.content {
grid-column: 3 / 4;
grid-row: 3 / 4;
}
.quote {
grid-column: 3 / 4;
grid-row: 2 / 3;
}
}
@media only screen and (min-width: 980px) {
.wrapper {
grid-template-columns: 200px 40px auto 40px 200px;
grid-template-rows: auto ;
max-width: 960px;
}
.mainnav {
grid-column: 1 / 2;
grid-row: 2 / 3;
}
.subhead {
grid-row: 1 / 2;
grid-column: 3 / 4;
}
.content {
grid-column: 3 / 4;
grid-row: 2 / 3;
}
.quote {
grid-column: 5 / 6;
grid-row: 2 / 3;
}
}
Also see: Tab Triggers