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.
<header id="main-header">
<h1>ANIMAL NEWS</h1>
<nav id="main-nav">
<a href="">News</a>
<a href="">Zoo Life</a>
<a href="">Pets</a>
<a href="">About Us</a>
<a href="">Contact</a>
</nav>
</header>
<div class="container">
<section id="feature-cards">
<div class="card card1">
<div class="card-content">
<h3>Quam Optio ab Modi!</h3>
<p class="date">Nov 12, 2016</p>
</div>
</div>
<div class="card card2">
<div class="card-content">
<h3>At Doloremque Aperiam Amet.</h3>
<p class="date">Nov 2, 2016</p>
</div>
</div>
<div class="card card3">
<div class="card-content">
<h3>Eveniet Consequuntur, Odit Laboriosam?</h3>
<p class="date">Oct 30, 2016</p>
</div>
</div>
<div class="card card4">
<div class="card-content">
<h3>Nihil Itaque Corporis Architecto Reprehenderit</h3>
<p class="date">Oct 30, 2016</p>
</div>
</div>
<div class="card card5">
<div class="card-content">
<h3>In fugit possimus maiores</h3>
<p class="date">Oct 22, 2016</p>
</div>
</div>
<div class="card card6">
<div class="card-content">
<h3>Rem Voluptate, Tempora Praesentium.</h3>
<p class="date">Oct 12, 2016</p>
</div>
</div>
<div class="card card7">
<div class="card-content">
<h3>Dolorem Doloribus Libero</h3>
<p class="date">Oct 10, 2016</p>
</div>
</div>
</section>
<section id="feature-articles">
<article class="feature">
<img src="http://lorempixel.com/500/300/animals/8">
<div class="feature-text">
<h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</h3>
<div class="feature-meta">
<span class="category">Felines</span>
<span class="author">Jimmy Frost</span>
<span class="date">Nov 15, 2016</span>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nobis dolor enim mollitia a quasi sunt tempore, recusandae illo provident fugit distinctio ipsum odit porro neque tenetur earum quas eveniet quisquam.</p>
<button>Read More</button>
</div>
</article>
<article class="feature">
<img src="http://lorempixel.com/500/300/animals/9">
<div class="feature-text">
<h3>Eos Quam Sint Molestias Perferendis Totam</h3>
<div class="feature-meta">
<span class="category">Pets</span>
<span class="author">Jimmy Frost</span>
<span class="date">Nov 10, 2016</span>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nobis dolor enim mollitia a quasi sunt tempore, recusandae illo provident fugit distinctio ipsum odit porro neque tenetur earum quas eveniet quisquam.</p>
<button>Read More</button>
</div>
</article>
</section>
<aside id="sidebar">
<h4 class="section-title"><span>Adopt a Pet</span></h4>
<div class="pets">
<div class="card">
<img src="http://lorempixel.com/300/300/animals/9"/>
<h4>Rover</h4>
</div>
<div class="card">
<img src="http://lorempixel.com/300/300/animals/7"/>
<h4>Whiskers</h4>
</div>
<div class="card">
<img src="http://lorempixel.com/300/300/animals/6"/>
<h4>Eugene</h4>
</div>
</div>
</aside>
<section id="archives">
<h4 class="section-title"><span>In the Archives</span></h4>
<div class="archive-cards">
<div class="card card1">
<h4>Perferendis Laboriosam Amet Eveniet</h4>
<p class="date">Sept 28, 2016</p>
</div>
<div class="card card2">
<h4>Deserunt Consequuntur Neque, Minus Quibusdam Sint.</h4>
<p class="date">Sept 18, 2016</p>
</div>
<div class="card card3">
<h4>Quibusdam Facere Quis Officia Consequuntur</h4>
<p class="date">Sept 4, 2016</p>
</div>
</div>
</section>
</div>
<footer id="main-footer">
©Copyright 2016
</footer>
html, body { font-family: Arial, sans-serif; margin: 0; color: #333; }
h1,h2,h3,h4,h5,h6 { font-family: Georgia, serif; }
.section-title {
border-bottom: 1px solid #333;
font-weight: normal;
font-family: Arial, sans-serif;
font-size: 14px;
margin-top: 4px;
}
.section-title span {
background-color: #333;
color: #fff;
padding: 4px 8px;
display: inline-block;
}
#main-header {
text-align: center;
border-bottom: 4px solid #c44c4c;
}
#main-header h1 {
font-size: 60px;
font-weight: normal;
margin: 40px;
}
#main-nav {
display: flex;
justify-content: space-between;
width: 740px;
margin: 0 auto;
}
#main-nav a {
text-decoration: none;
font-family: Georgia, serif;
color: #333;
padding-bottom: 10px;
}
#main-nav a:hover { color: #c44c4c; }
.container {
width: 740px;
margin: 0 auto;
display: grid;
grid-gap: 40px;
grid-template-columns: 2fr 1fr;
grid-template-areas: "cards cards"
"articles sidebar"
"archives archives";
}
#feature-cards {
padding-top: 20px;
width: 740px;
margin: 0 auto;
grid-area: cards;
}
#feature-cards .card h3 {
font-size: 14px;
font-weight: normal;
color: #fff;
margin: 0;
}
#feature-cards .card p {
margin: 0;
color: #fff;
font-size: 10px;
}
#feature-cards .card { text-align: center; }
#feature-cards .card1 {
background: url('http://lorempixel.com/300/200/animals/1') center center no-repeat;
}
#feature-cards .card2 {
background: url('http://lorempixel.com/300/200/animals/2') center center no-repeat;
}
#feature-cards .card3 {
background: url('http://lorempixel.com/300/200/animals/3') center center no-repeat;
}
#feature-cards .card4 {
background: url('http://lorempixel.com/300/200/animals/4') center center no-repeat;
}
#feature-cards .card5 {
background: url('http://lorempixel.com/300/200/animals/5') center center no-repeat;
}
#feature-cards .card6 {
background: url('http://lorempixel.com/300/200/animals/6') center center no-repeat;
}
#feature-cards .card7 {
background: url('http://lorempixel.com/300/200/animals/7') center center no-repeat;
}
#feature-cards .card .card-content {
background-color: rgba(30,30,30,.5);
height: 100%;
}
#feature-articles {
grid-area: articles;
}
#feature-articles .feature img {
width: 100%;
}
.feature .feature-text {
position: relative;
top: -80px;
padding: 10px 10px 10px 0;
width: 90%;
background-color: #fff;
}
.feature-text h3 {
margin: 0;
font-size: 28px;
}
.feature-text h3:hover {
color: #c44c4c;
}
.feature-meta {
margin: 8px 0;
font-size: 12px;
}
.feature-meta .category {
background-color: #333;
color: #fff;
padding: 2px 8px;
}
.feature-meta .author {
font-weight: bold;
margin: 0 8px;
}
.feature-meta .date {
color: #999;
}
.feature p {
font-size: 14px;
color: #999;
}
.feature button {
background-color: #c44c4c;
border: none;
color: #fff;
padding: 4px 8px;
}
#sidebar {
grid-area: sidebar;
}
#sidebar .card {
clear: both;
}
#sidebar .card h4 {
float: right;
background-color: #fff;
position: relative;
padding: 8px;
top: -50px;
margin-bottom: -30px;
}
#archives {
grid-area: archives;
}
.archive-cards h4 {
color: #c44c4c;
margin: 2px;
}
.archive-cards .date {
margin: 0;
font-size: 12px;
color: #999;
}
#main-footer {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
font-size: 12px;
}
Also see: Tab Triggers