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.
<h1>Blocks</h1>
<h2>Block Links</h2>
<div>
<article class="default">
<a href="https://example.com/linkwrap" rel="nofollow">
<h3>Wrapping Entire Thing</h3>
<img src="https://www.fillmurray.com/640/360" width="640" height="360" alt="Bill Murray on the award carpet.">
<p>
Gastropub sartorial venmo hashtag, franzen actually umami small batch vinyl taiyaki. Seitan organic dreamcatcher
pinterest, tilde franzen ugh tattooed PBR&B etsy bitters brooklyn yuccie listicle bicycle rights. Keytar
keffiyeh glossier roof party. YOLO palo santo godard, organic lomo roof party tumeric affogato bicycle rights.
</p>
</a>
</article>
<article class="block">
<h3><a href="https://example.com/heading" rel="nofollow">Only on Heading</a></h3>
<img src="https://www.fillmurray.com/600/380" width="600" height="380" alt="Bill Murray in a still from Caddyshack.">
<p>
Tumeric prism tattooed, raw denim cloud bread 90's cred plaid shabby chic aesthetic scenester snackwave
fingerstache gochujang twee. Crucifix readymade hoodie +1 tote bag stumptown iceland umami. Edison bulb plaid
vegan activated charcoal la croix vape paleo shabby chic slow-carb taiyaki. Pour-over cliche slow-carb unicorn.
</p>
</article>
<article class="block">
<h3 id="A3">Somewhere in the Text</h3>
<img src="https://www.fillmurray.com/580/320" width="580" height="320" alt="Close-up black-and-white of Bill Murray">
<p>
Sriracha actually cred portland beard kickstarter williamsburg direct trade cardigan brooklyn pinterest vape paleo
readymade iPhone. Narwhal helvetica hammock mixtape aesthetic ramps shaman mustache try-hard small batch bicycle
rights meh. Green juice tacos twee, offal everyday carry la croix PBR&B. Try-hard roof party flannel. <a
href="https://example.com/text" rel="nofollow" aria-describedby="A3">Read more…</a>
</p>
</article>
</div>
<h2>Block Link Variations</h2>
<div>
<article class="block reorder">
<h3><a href="https://example.com/re-ordered" rel="nofollow">Art Visually Above Heading</a></h3>
<img src="https://placekitten.com/680/380" width="680" height="380" alt="Kitten resting against a scratching post.">
<p>
This looks perfect. Just Photoshop out the dog, add a baby, and make the curtains blue. There are more projects
lined up; charge extra the next time. Can you make the logo bigger? Yes, bigger. Bigger still. The logo is too
big. You can get my logo from Facebook. The target audience is males and females aged zero and up, so make it
original. Can you rework to make the pizza look more delicious?
</p>
</article>
<article class="block reorder extracta">
<h3><a href="https://example.com/extraCTA" rel="nofollow">With Another Call to Action</a></h3>
<img src="https://placekitten.com/600/320" width="600" height="320" alt="Kitten staring into camera.">
<p>
What do you feel you would bring to the table if you were hired for this position? Core competencies? Blue sky
wheelhouse. Product market fit shelfware performance review. Please use "solutionise" instead of solution ideas!
Proceduralize. Can I just chime in on that one, get all your ducks in a row, so corporate synergy.
</p>
<p>
<a href="https://example.com/" rel="nofollow">Order Your Own!</a>
</p>
</article>
</div>
<h2>Block Buttons</h2>
<div>
<section class="default">
<button type="button" onclick="alert('You look nice in those shoes.');">
<h3>Wrapping Entire Thing</h3>
<p>
Hundreds of thousands how far away not a sunrise but a galaxyrise paroxysm of global death gathered by gravity
preserve and cherish that pale blue dot?
</p>
<p>
<span>Settings</span>
</p>
</button>
</section>
<section class="block">
<h3>Only on Settings Text</h3>
<p>
Hundreds of thousands how far away not a sunrise but a galaxyrise paroxysm of global death gathered by gravity
preserve and cherish that pale blue dot?
</p>
<button type="button" onclick="alert('You look nice in that shirt.');">
<span>Settings</span>
</button>
</section>
</div>
<p>
Used in my blog post <cite><a href="https://adrianroselli.com/2020/02/block-links-cards-clickable-regions-etc.html">Block Links, Cards, Clickable Regions, Etc.</a></cite>.
</p>
body {
font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto,
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
line-height: 1.4;
/* line-height: 1.5; */
/* letter-spacing: 0.12em; */
/* word-spacing: 0.16em; */
color: #333;
background: #efefef;
}
div {
display: flex;
justify-content: center;
flex-wrap: wrap;
}
div > * {
padding: .5em 1em;
margin: 0 0.5em 1em 0.5em;
flex: 0 1 20em;
border: .2em solid rgba(0,0,0,.15);
border-radius: 1em;
background-color: #fff;
}
img {
max-width: 100%;
height: auto;
}
h3 {
margin: .2em 0;
line-height: 1.2;
}
p {
margin: .2em 0;
}
a:focus, a:hover {
text-decoration: none;
}
.default a:link {
text-decoration: none;
color: #333;
}
.default a:focus h3, .default a:hover h3 {
color: #00f;
text-decoration: underline;
}
button {
font: inherit;
width: 100%;
text-align: left;
background: transparent;
border: none;
padding: 0;
margin: 0;
}
button:focus, button:hover {
outline: none;
}
button span {
display: block;
text-align: center;
padding: .5em 1em;
margin: .5em 1em;
border: .1em solid #00c;
border-radius: .25em;
background-color: #00c;
color: #fff;
}
button:focus span, button:hover span {
color: #00c;
background-color: #fff;
}
/* Move the image above the heading */
.reorder {
display: flex;
flex-direction: column;
padding-top: .5em;
}
.reorder img {
/* see comment on post */
order: -1;
}
/* .reorder h3 {
order: 2;
}
.reorder p {
order: 3;
} */
/* Block links */
.block {
position: relative;
}
.block a[href]::after, .block button::after {
content: "";
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.block:hover, .block:focus-within, .default:hover, .default:focus-within {
border-color: rgba(0,0,255,.5);
box-shadow: 0 0 .5em rgba(0,0,0,.25);
}
/* Help out IE */
.block a[href]:hover, .block a[href]:focus {
outline: .4em solid rgba(0,0,255,.25);
outline-offset: .25em;
}
/* Undo the IE */
.block:hover a[href]:hover, .block:hover a[href]:focus, .block:hover button:focus, .block:hover button:hover, .block:focus-within a[href]:hover, .block:focus-within a[href]:focus, .block:focus-within button:focus, .block:focus-within button:hover {
outline: none;
}
/* ------------------------------------ */
/* Now with another link in the block thinger */
.block.extracta a[href]::after {
bottom: 3.75em;
}
.block.extracta p a[href]::after {
content: none;
}
.block.extracta p a[href] {
display: block;
text-align: center;
margin: 1em 2em 0 2em;
padding: .5em 1em;
border: .1em solid #00c;
border-radius: .25em;
text-decoration: none;
color: #fff;
background-color: #00c;
}
.block.extracta p a[href]:focus, .block.extracta p a[href]:hover {
color: #00c;
background-color: #fff;
}
Also see: Tab Triggers