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="cards">
<div class="card">
<h2 class="card__title">
Some really important news takes place
</h2>
<img class="card__image" src="https://source.unsplash.com/o0kbc907i20/900x600" alt="Government monument building">
<div class="card__body">
<div class="card__taxon">
<svg class="card__clock-icon" width="12" height="12" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><circle cx="5" cy="5" r="5"/><path d="M5 1.667V5M6.667 6.667L5 5" stroke-linecap="round"/></g></svg>
<p class="card__publish">Posted: Apr. 10, 2018 at 10:38 a.m.</p>
</div>
<p class="card__summary">Earlier today, this super important thing happened that is going to change everything. You won’t even believe how much this thing will matter forever going forward.</p>
<a href="#0" class="card__cta">Read more →</a>
</div>
</div>
<div class="card">
<h2 class="card__title">
Other extra special stuff occurs
</h2>
<img class="card__image" src="https://source.unsplash.com/45sjAjSjArQ/900x600" alt="Busy stairs in large building">
<div class="card__body">
<div class="card__taxon">
<svg class="card__clock-icon" width="12" height="12" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><circle cx="5" cy="5" r="5"/><path d="M5 1.667V5M6.667 6.667L5 5" stroke-linecap="round"/></g></svg>
<p class="card__publish">Posted: Apr. 8, 2018 at 5:23 p.m.</p>
</div>
<p class="card__summary">In a suprising turn of events, this unexpected event took place and shocked the world.</p>
<a href="#0" class="card__cta">Read more →</a>
</div>
</div>
<div class="card">
<h2 class="card__title">
Very significant announcement made
</h2>
<img class="card__image" src="https://source.unsplash.com/DurC25GdOvk/900x600" alt="Rows of voting seats in political building">
<div class="card__body">
<div class="card__taxon">
<svg class="card__clock-icon" width="12" height="12" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><circle cx="5" cy="5" r="5"/><path d="M5 1.667V5M6.667 6.667L5 5" stroke-linecap="round"/></g></svg>
<p class="card__publish">Posted: Apr. 7, 2018 at 6:42 a.m.</p>
</div>
<p class="card__summary">Jargony jargon was communicated widely to a boring commmitee on Thursday.</p>
<a href="#0" class="card__cta">Read more →</a>
</div>
</div>
<div class="card">
<h2 class="card__title">
Leader loudly declares decision
</h2>
<img class="card__image" src="https://source.unsplash.com/aNSniQXO424/900x600" alt="News photographers documenting event">
<div class="card__body">
<div class="card__taxon">
<svg class="card__clock-icon" width="12" height="12" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" fill="none" fill-rule="evenodd"><circle cx="5" cy="5" r="5"/><path d="M5 1.667V5M6.667 6.667L5 5" stroke-linecap="round"/></g></svg>
<p class="card__publish">Posted: Apr. 6, 2018 at 4:54 p.m.</p>
</div>
<p class="card__summary">Do people even read beyond the headlines anymore? Hello? Anyone?!?</p>
<a href="#0" class="card__cta">Read more →</a>
</div>
</div>
</div>
@use postcss-nested;
@import url("https://fonts.googleapis.com/css?family=Poppins:200,300,800");
html {
font-family: "Poppins";
}
body {
padding: 20px;
}
.cards {
display: flex;
flex-flow: row wrap;
justify-content: center;
}
.card {
margin-right: var(--card-margin-right);
margin-left: var(--card-margin-left);
margin-bottom: 20px;
padding: var(--card-padding);
width: var(--card-width);
display: grid;
grid-template-areas: var(--card-template-areas);
grid-template-columns: var(--card-template-columns);
grid-template-rows: var(--card-template-rows);
grid-row-gap: 20px;
grid-column-gap: var(--card-column-gap);
align-items: var(--card-align-items);
border: 1px solid #ddd;
border-radius: 3px;
overflow: hidden;
@media (max-width: 899px) {
--card-width: 300px;
--card-template-areas:
"card__image card__image card__image"
". card__title ."
". card__body .";
--card-template-columns: 20px 1fr 20px;
--card-template-rows: auto;
}
@media (min-width: 640px) and (max-width: 899px) {
--card-margin-right: 10px;
--card-margin-left: 10px;
}
@media (min-width: 900px) {
--card-padding: 20px 20px 0 20px;
--card-width: 100%;
--card-template-areas:
"card__title card__image"
"card__body card__image";
--card-template-columns: 1fr 2fr;
--card-template-rows: 1fr 3fr;
--card-column-gap: 20px;
--card-align-items: start;
}
}
.card__image {
max-width: 100%;
grid-area: card__image;
}
.card__title {
margin: 0;
grid-area: card__title;
font-size: var(--card-title-font-size);
font-weight: 800;
line-height: 1.1;
@media (min-width: 900px) {
--card-title-font-size: 28px;
}
}
.card__body {
grid-area: card__body;
}
.card__taxon {
margin: 0 0 12px;
font-size: 12px;
font-weight: 200;
color: #888;
}
.card__summary {
margin: 0 0 20px;
font-size: 14px;
font-style: italic;
font-weight: 300;
line-height: 1.4;
color: #333;
}
.card__cta {
margin-bottom: 20px;
display: inline-block;
grid-area: card__cta;
justify-self: start;
text-decoration: none;
border-bottom: 4px solid blue;
&:hover {
color: #4d4dff;
border-color: #4d4dff;
}
}
Also see: Tab Triggers