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="wrapper">
<!-- Row 1: One box per column -->
<figure>
<div class="one"></div>
<figcaption>
<h2>Abstract 1</h2>
<p>Lorem ipsum dolor sit amet.</p>
</figcaption>
</figure>
<figure>
<div class="two"></div>
<figcaption>
<h2>Abstract 2</h2>
<p>Lorem ipsum dolor sit amet.</p>
</figcaption>
</figure>
<figure>
<div class="three"></div>
<figcaption>
<h2>Abstract 3</h2>
<p>Lorem ipsum dolor sit amet.</p>
</figcaption>
</figure>
<figure>
<div class="four"></div>
<figcaption>
<h2>Abstract 4</h2>
<p>Lorem ipsum dolor sit amet.</p>
</figcaption>
</figure>
<!-- Row 2: 2 boxes, each spanning 2 columns -->
<figure class="span2">
<div class="three"></div>
<figcaption>
<h2>Abstract 3</h2>
<p>Lorem ipsum dolor sit amet.</p>
</figcaption>
</figure>
<figure class="span2">
<div class="one"></div>
<figcaption>
<h2>Abstract 1</h2>
<p>Lorem ipsum dolor sit amet.</p>
</figcaption>
</figure>
<!-- Row 3: One box spans 3 columns, one box spans 1 column -->
<figure class="span3">
<div class="four"></div>
<figcaption>
<h2>Abstract 4</h2>
<p>Lorem ipsum dolor sit amet.</p>
</figcaption>
</figure>
<figure>
<div class="two"></div>
<figcaption>
<h2>Abstract 2</h2>
<p>Lorem ipsum dolor sit amet.</p>
</figcaption>
</figure>
<!-- Row 4: One box spans 4 columns -->
<figure class="span4">
<div class="three"></div>
<figcaption>
<h2>Abstract 3</h2>
<p>Lorem ipsum dolor sit amet.</p>
</figcaption>
</figure>
<!-- Row 5: 3 boxes, 1-2-1 distribution -->
<figure>
<div class="four"></div>
<figcaption>
<h2>Abstract 4</h2>
<p>Lorem ipsum dolor sit amet.</p>
</figcaption>
</figure>
<figure class="span2">
<div class="two"></div>
<figcaption>
<h2>Abstract 2</h2>
<p>Lorem ipsum dolor sit amet.</p>
</figcaption>
</figure>
<figure>
<div class="one"></div>
<figcaption>
<h2>Abstract 1</h2>
<p>Lorem ipsum dolor sit amet.</p>
</figcaption>
</figure>
</div>
.wrapper {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: auto;
gap: 4%;
}
.span2 {
grid-column: span 2;
}
.span3 {
grid-column: span 3;
}
.span4 {
grid-column: span 4;
}
/* default styling, no changes needed here */
/* set the layout to border box model */
html {
box-sizing: border-box;
}
*, *::before, *::after {
box-sizing: inherit;
}
/* set font family and background gradient */
body {
padding: 0;
border: 0;
font-family: Arial, sans-serif;
background: linear-gradient(353deg, rgba(148,210,189,1) 40%, rgba(61,147,151,1) 100%);
}
/* Turn off margin, set by browser */
figure {
margin: 0;
padding: 0;
}
/* caption styling */
figcaption {
background-color: #001219;
color: white;
padding: 1rem;
}
/* reduces the top margin on the h2, bottom on the p, and leaves a 0.5rem gap between the two */
figcaption * {
margin: 0.5rem;
}
/* sets the background SVG for all divs, regardless of color */
figure > div {
background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 56 28" width="56" height="28"%3E%3Cpath fill="%239C92AC" fill-opacity="0.4" d="M56 26v2h-7.75c2.3-1.27 4.94-2 7.75-2zm-26 2a2 2 0 1 0-4 0h-4.09A25.98 25.98 0 0 0 0 16v-2c.67 0 1.34.02 2 .07V14a2 2 0 0 0-2-2v-2a4 4 0 0 1 3.98 3.6 28.09 28.09 0 0 1 2.8-3.86A8 8 0 0 0 0 6V4a9.99 9.99 0 0 1 8.17 4.23c.94-.95 1.96-1.83 3.03-2.63A13.98 13.98 0 0 0 0 0h7.75c2 1.1 3.73 2.63 5.1 4.45 1.12-.72 2.3-1.37 3.53-1.93A20.1 20.1 0 0 0 14.28 0h2.7c.45.56.88 1.14 1.29 1.74 1.3-.48 2.63-.87 4-1.15-.11-.2-.23-.4-.36-.59H26v.07a28.4 28.4 0 0 1 4 0V0h4.09l-.37.59c1.38.28 2.72.67 4.01 1.15.4-.6.84-1.18 1.3-1.74h2.69a20.1 20.1 0 0 0-2.1 2.52c1.23.56 2.41 1.2 3.54 1.93A16.08 16.08 0 0 1 48.25 0H56c-4.58 0-8.65 2.2-11.2 5.6 1.07.8 2.09 1.68 3.03 2.63A9.99 9.99 0 0 1 56 4v2a8 8 0 0 0-6.77 3.74c1.03 1.2 1.97 2.5 2.79 3.86A4 4 0 0 1 56 10v2a2 2 0 0 0-2 2.07 28.4 28.4 0 0 1 2-.07v2c-9.2 0-17.3 4.78-21.91 12H30zM7.75 28H0v-2c2.81 0 5.46.73 7.75 2zM56 20v2c-5.6 0-10.65 2.3-14.28 6h-2.7c4.04-4.89 10.15-8 16.98-8zm-39.03 8h-2.69C10.65 24.3 5.6 22 0 22v-2c6.83 0 12.94 3.11 16.97 8zm15.01-.4a28.09 28.09 0 0 1 2.8-3.86 8 8 0 0 0-13.55 0c1.03 1.2 1.97 2.5 2.79 3.86a4 4 0 0 1 7.96 0zm14.29-11.86c1.3-.48 2.63-.87 4-1.15a25.99 25.99 0 0 0-44.55 0c1.38.28 2.72.67 4.01 1.15a21.98 21.98 0 0 1 36.54 0zm-5.43 2.71c1.13-.72 2.3-1.37 3.54-1.93a19.98 19.98 0 0 0-32.76 0c1.23.56 2.41 1.2 3.54 1.93a15.98 15.98 0 0 1 25.68 0zm-4.67 3.78c.94-.95 1.96-1.83 3.03-2.63a13.98 13.98 0 0 0-22.4 0c1.07.8 2.09 1.68 3.03 2.63a9.99 9.99 0 0 1 16.34 0z"%3E%3C/path%3E%3C/svg%3E');
width: 100%;
min-height: 150px;
}
/* sets a specific background color for each div */
.one {
background-color: #9b2226;
}
.two {
background-color: #bb3e03;
}
.three {
background-color: #ee9b00;
}
.four {
background-color: #005f73;
}
/* Same instructions as before -- the HTML will tell you how many boxes per row. There should be 4 columns, just as we did with Flexbox.
However, this time, you should not need to mark each row individually. Because this is Grid, you should have enough markup here to set this up without adding extra divs.
You may need to add some classes to designate how large each box should be. Consider what your default value is - those boxes don't need a class. */
Also see: Tab Triggers