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.
<!-- Sidebar container -->
<aside class="site-sidebar">
<h3>Sidebar</h3>
<p>Lorem ipsum dolor sit amet, ferri vidisse nam eu, ad nec copiosae mnesarchum vituperatoribus. Te brute dicunt sea, ut vis omnium menandri, ut sumo aliquam has. Eum aperiam interpretaris at, sea et recusabo expetenda, omnis tibique mea no. Pri suas partem ea, ius sonet numquam offendit cu, ad simul admodum pri. Eum cu unum choro albucius.</p>
<p>Eu integre accusata prodesset est, sed te impetus gubergren conceptam, ex sed wisi nostrum ocurreret. Esse velit omittantur ius te, alii dissentias ei vis. At sed unum veritus fabellas. Te volutpat appellantur duo. Ad natum fuisset intellegebat eam, causae invidunt usu id, et vis impetus appetere.</p>
</aside>
<!-- Main content container -->
<article class="site-content">
<figure class="wp-block-image alignfull">
<img src="https://cldup.com/m7_aXlDCXw.jpg" alt="">
</figure>
<p>Full-wide image above 👆</p>
<h2>Wide images, floats, and sidebars in Gutenberg</h2>
<p>The big change since <a href="https://codepen.io/joen/pen/oEYVXB">last time</a> is that now any floated image has a wrapping <code>div</code> container.</p>
<div class="wp-block-image">
<figure class="alignleft">
<img src="https://cldup.com/yPKF2vjugC.jpg" alt="" width="200px">
<figcaption>Short image caption.</figcaption>
</figure>
</div>
<p>Est quis reque cetero ad. Sea id autem nominavi deseruisse. Veniam qualisque definitionem pri id, ea autem feugiat delenit ius, mei at lorem affert accumsan. Dicat eruditi cu est, te pro dicant pericula conclusionemque, ei vim detracto euripidis intellegam.
Eius postea volumus mei ad.</p>
<p>Prima ridens denique his te, ferri illum volumus an his. Eu vel dicat homero qualisque, vitae regione deserunt vis ei. Graeci incorrupte liberavisse no mea, saepe voluptaria usu ex, vis dicant euismod id. At dolor reprimique eos, quo altera detraxit
moderatius id. Quo iudico utinam eu, ad alia munere mel.</p>
<div class="wp-block-image">
<figure class="alignright">
<img src="https://cldup.com/lUUQPv6w9c.jpg" alt="" width="200px">
<figcaption>Really quite long image caption, one that absolutely spans multiple lines. Holy guacamole who would ever write this much in a caption?.</figcaption>
</figure>
</div>
<p>Lorem ipsum dolor sit amet, ferri vidisse nam eu, ad nec copiosae mnesarchum vituperatoribus. Te brute dicunt sea, ut vis omnium menandri, ut sumo aliquam has. Eum aperiam interpretaris at, sea et recusabo expetenda, omnis tibique mea no. Pri suas partem
ea, ius sonet numquam offendit cu, ad simul admodum pri. Eum cu unum choro albucius.</p>
<p>Eu integre accusata prodesset est, sed te impetus gubergren conceptam, ex sed wisi nostrum ocurreret. Esse velit omittantur ius te, alii dissentias ei vis. At sed unum veritus fabellas. Te volutpat appellantur duo. Ad natum fuisset intellegebat eam,
causae invidunt usu id, et vis impetus appetere.</p>
<p>Wide image below 👇</p>
<figure class="wp-block-image alignwide">
<img src="https://cldup.com/kAIpBuzEXf.jpg" alt="">
</figure>
<p>Est quis reque cetero ad. Sea id autem nominavi deseruisse. Veniam qualisque definitionem pri id, ea autem feugiat delenit ius, mei at lorem affert accumsan. Dicat eruditi cu est, te pro dicant pericula conclusionemque, ei vim detracto euripidis intellegam.
Eius postea volumus mei ad.</p>
<p>Prima ridens denique his te, ferri illum volumus an his. Eu vel dicat homero qualisque, vitae regione deserunt vis ei. Graeci incorrupte liberavisse no mea, saepe voluptaria usu ex, vis dicant euismod id. At dolor reprimique eos, quo altera detraxit
moderatius id. Quo iudico utinam eu, ad alia munere mel.</p>
</article>
/**
* Base styles
*/
body {
margin: 0;
font-size: 14pt;
line-height: 1.6;
}
* {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
p {
margin: 2em 0;
}
figure {
margin: 0; /* Remember this one, figures are born with margins */
text-align: center;
}
img {
max-width: 100%;
height: auto;
}
/**
* Sidebar and main column
*/
.site-content {
width: 80%; /* Could be a pixel value too */
border-right: 1px solid #eee;
}
.site-sidebar {
width: 20%;
float: right;
background: #fefefe;
height: 100%;
padding: 20px;
}
/**
* Fullwide CSS
*/
/* Unconstrained main colum */
.site-content > *:not( .alignwide ):not( .alignfull ) {
max-width: 50%; /* Could be a pixel value too: this is the one that decides the width of the text */
margin-left: auto;
margin-right: auto;
}
.wp-block-image.alignfull {
display: block;
text-align: center;
}
.wp-block-image.alignwide {
max-width: 75%; /* Could be a pixel value too */
margin-left: auto;
margin-right: auto;
}
/* We float the img inside the figure that has .alignleft applied.
This makes the .alignleft element have the same main column width as text.
What makes the float work is that the figure collapses into a zero height element */
.wp-block-image figure.alignleft {
display: block;
float: left;
margin-right: 2em;
}
.wp-block-image figure.alignright {
display: block;
float: right;
margin-left: 2em;
}
/* For captions, we display the figure itself as a table.
This ensures the figcaption will retain the same width as the image,
which is important when the caption is long. */
.wp-block-image figure.alignleft,
.wp-block-image figure.alignright {
display: table;
}
.wp-block-image figure.alignleft figcaption,
.wp-block-image figure.alignright figcaption {
display: table-caption;
caption-side: bottom;
}
.wp-block-image figure.alignright figcaption,
.wp-block-image figure.alignleft figcaption {
font-size: 75%;
color: gray;
margin-bottom: 1em;
}
Also see: Tab Triggers