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.
<section class="content">
<a href="#openModal">
<figure>
<img src="https://placekitten.com/289/220" />
<figcaption>
Click the photo to load cute kitty!
</figcaption>
</figure>
</a>
<p>
Etiam ultrices, augue in eleifend commodo, ex mi vulputate massa, ut convallis elit mi at quam. Etiam aliquet non massa in auctor. Nunc sagittis ac felis sit amet cursus. Suspendisse dictum, purus in accumsan rutrum, nibh urna gravida purus, sit amet aliquam eros est eu ex. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam efficitur mauris leo, at consectetur magna malesuada vitae. Morbi consectetur eget ipsum vitae cursus. Praesent lacinia ultricies tempor. Quisque dictum feugiat est, in gravida tortor tincidunt sed. Aliquam erat volutpat. Etiam dictum suscipit dolor. Nam dictum cursus diam non suscipit.
</p>
<p>
Donec velit sapien, finibus quis purus nec, ullamcorper dictum enim. Integer vitae ullamcorper enim. Aenean commodo lorem et augue accumsan tincidunt. Pellentesque sapien justo, feugiat in diam vitae, efficitur vehicula ligula. Morbi in tellus ut mauris pulvinar lacinia. Curabitur ac maximus lacus, ut lacinia nunc. Nunc pharetra nibh vitae nunc ornare, sed tincidunt neque aliquet. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam efficitur ut turpis sed porta. Duis commodo tincidunt ipsum, sit amet egestas dolor bibendum vel. Integer nec magna turpis. Curabitur aliquet lobortis odio, nec facilisis ipsum.
</p>
<p>
Donec scelerisque aliquet tristique. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean dictum urna id placerat sagittis. Vestibulum et interdum urna, pulvinar volutpat eros. Fusce consequat rhoncus nisl, vel malesuada nulla lacinia sit amet. Nulla in aliquet magna, eu malesuada orci. Nullam ligula lacus, sollicitudin ac metus a, condimentum efficitur ligula. Aliquam posuere, magna eget fringilla ornare, purus tortor ullamcorper eros, ut fringilla justo dolor eu est. Fusce sagittis lacus et finibus tincidunt.
</p>
<p>
Aenean et egestas erat. Nullam aliquam tortor quis nulla feugiat, ac aliquet neque euismod. Aenean auctor risus sed nibh feugiat, vel volutpat elit finibus. Vestibulum vulputate leo vel ex porttitor, at sodales purus mattis. Suspendisse vulputate nisl id erat ultricies, commodo tempor lectus mattis. Sed turpis tortor, tincidunt quis viverra in, laoreet at diam. Donec varius turpis nisi, vitae blandit felis gravida eget. Aenean vitae molestie leo. In sapien mi, ultrices a arcu in, sodales lobortis elit. Pellentesque sit amet nibh at ex iaculis venenatis. Quisque sed orci vel lorem congue sodales.
</p>
<!-- Modal -->
<div id="openModal" class="modal">
<div class="modal__content">
<a href="#" class="close">+</a>
<b>MEOW MEOW MEOW</b>
<img src="https://www.dropbox.com/s/mqapcs2hsf7k4yp/cat-expressions_03.png?dl=1" />
</div>
</div>
</section>
<div class="side-tab">
Send Feedback
</div>
$bodyBg: #030018;
$purple: #292477;
$green: #13693B;
$magenta: #AD2266;
$blue: #1a28b3;
html {
box-sizing: border-box;
font-size: 100%;
}
*, *:before, *:after {
box-sizing: inherit;
}
body {
margin: 0;
padding: 0;
position: relative;
background: #cecece;
color: $bodyBg;
font-family: 'Roboto', sans-serif;
font-size: 1rem;
line-height: 1.3;
}
h1 {
font-size: 2.5rem;
}
h2 {
font-size: 1.5rem;
}
a, a:visited {
text-decoration: none;
}
h1, h2 {
margin: 0 0 30px;
}
.content {
position: relative;
z-index: 1;
padding: 30px;
figure {
float: left;
margin: 10px 20px 10px 0;
img {
margin: 0;
}
figcaption {
font-size: 0.9rem;
text-align: center;
background-color: #333333;
color: #ffffff;
margin-top: -6px;
padding: 8px;
}
}
}
.modal { // background overlay
display: none;
position: fixed;
z-index: 100;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(0,0,0,0.2);
transition: opacity 300ms ease-in-out;
&:target {
display: block;
}
&__content { // modal content
position: absolute;
width: 100%;
max-width: 240px;
margin: 20px auto;
padding: 20px;
background-color: #ffffff;
top: 45%;
left: 50%;
border-radius: 20px;
box-shadow: 0 0 10px rgba(0,0,0,0.25);
transform: translateX(-50%) translateY(-50%);
pointer-events: auto;
}
img {
width: 140px;
}
.close {
display: block;
position: absolute;
top: -26px;
right: 3px;
padding: 40px 5px;
font-size: 60px;
line-height: 23px;
color: rgba(0,0,0,0.75);
transform: rotate(45deg);
cursor: pointer;
transition: all 50ms ease-in-out;
&:hover {
color: rgba(0,0,0,0.25);
}
}
}
.side-tab {
position: fixed;
z-index: 5;
bottom: 20%;
right: -71px;
padding: 15px 30px;
border-radius: 10px 10px 0 0;
background-color: $magenta;
color: #ffffff;
transform: rotate(-90deg);
box-shadow: 0 -3px 7px rgba(0,0,0,0.3);
}
Also see: Tab Triggers