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 id="app">
<article class="content">
<h1 class="content-title">Urna Cursus</h1>
<main class="content-body">
<p>Habitasse platea dictumst quisque sagittis purus sit. Ac feugiat sed lectus vestibulum mattis ullamcorper. Ultricies mi quis hendrerit dolor magna eget est lorem ipsum.</p>
<p>Adipiscing tristique risus nec feugiat in fermentum. Faucibus turpis in eu mi bibendum. Integer quis auctor elit sed vulputate mi. Urna nunc id cursus metus aliquam eleifend mi in. <span v-pq:left.italic.quoted.highlighted>Cras tincidunt lobortis feugiat vivamus at augue eget. Eget felis eget nunc lobortis mattis aliquam faucibus. Netus et malesuada fames ac turpis.</span></p>
<p>Dui faucibus in ornare quam viverra. Orci phasellus egestas tellus rutrum tellus pellentesque eu. Lacus sed turpis tincidunt id. Mollis nunc sed id semper. Dictum at tempor commodo ullamcorper. Faucibus scelerisque eleifend mi in. Enim nec dui nunc mattis enim ut tellus elementum sagittis. Purus viverra accumsan in nisl nisi scelerisque eu ultrices.</p>
<p>Dictumst quisque sagittis purus sit. Amet venenatis urna cursus eget. Volutpat consequat mauris nunc congue nisi vitae suscipit tellus. <span v-pq:right="'Add abbreviated pull quotes by adding strings as expressions to the v-pq directive.'">A custom, abbreviated message can also be shown instead of a selected text fragment, just by adding the message string as an expression to the directive. For example, an abbreviated pull-quote will be shown instead of this unnecessarily long pull-quote source.</span></p>
<p>Sit amet cursus sit amet dictum sit. Non blandit massa enim nec dui nunc mattis enim. Ornare arcu odio ut sem nulla pharetra diam sit. Faucibus ornare suspendisse sed nisi lacus sed viverra.</p>
<p>Ullamcorper dignissim cras tincidunt lobortis feugiat vivamus. Arcu odio ut sem nulla pharetra diam. Lacus suspendisse faucibus interdum posuere lorem ipsum dolor sit amet. Vestibulum lectus mauris ultrices eros. Est ullamcorper eget nulla facilisi. Sed euismod nisi porta lorem mollis.</p>
<p>At consectetur lorem donec massa sapien faucibus et molestie ac. <span v-pq:center>Elit scelerisque mauris pellentesque pulvinar pellentesque habitant morbi tristique. Urna condimentum mattis pellentesque id nibh tortor id aliquet lectus.</span> Ac tortor dignissim convallis aenean et tortor. Pellentesque elit eget gravida cum sociis natoque penatibus et magnis. Sit amet facilisis magna etiam tempor orci eu lobortis.</p>
<p>Tortor at auctor urna nunc id cursus metus. Pulvinar elementum integer enim neque volutpat. Vestibulum morbi blandit cursus risus at ultrices mi. Neque laoreet suspendisse interdum consectetur.</p>
<p>Non blandit massa enim nec dui nunc mattis enim ut. In vitae turpis massa sed elementum tempus egestas sed. Mauris vitae ultricies leo integer malesuada nunc vel risus. Pellentesque eu tincidunt tortor aliquam nulla facilisi. Commodo sed egestas egestas fringilla phasellus faucibus scelerisque eleifend donec. Mattis vulputate enim nulla aliquet porttitor lacus luctus accumsan. Morbi tristique senectus et netus.</p>
<p>Auctor neque vitae tempus quam pellentesque nec nam. Nisl rhoncus mattis rhoncus urna neque viverra justo. Nisi scelerisque eu ultrices vitae auctor eu augue. Sodales neque sodales ut etiam sit amet nisl. Mus mauris vitae ultricies leo. Tincidunt ornare massa eget egestas purus viverra accumsan in nisl. Venenatis lectus magna fringilla urna porttitor rhoncus dolor purus. Gravida dictum fusce ut placerat orci nulla pellentesque dignissim enim.</p>
<p>Sit amet purus gravida quis blandit turpis. Ultrices eros in cursus turpis. Lorem ipsum dolor sit amet consectetur adipiscing elit pellentesque. Diam vel quam elementum pulvinar etiam non quam lacus suspendisse. Viverra accumsan in nisl nisi. Gravida arcu ac tortor dignissim convallis aenean. Elementum nibh tellus molestie nunc non blandit. Ut ornare lectus sit amet. Feugiat vivamus at augue eget arcu dictum varius duis. Felis eget nunc lobortis mattis. Adipiscing enim eu turpis egestas pretium aenean pharetra.</p>
</main><!-- .content-body -->
</article><!-- .content -->
</div><!-- #app -->
/* Set default sizing for font and boxes */
:root {
font-size: 21px;
box-sizing: border-box;
}
/* Keep the browser edges little distant */
#app {
padding: 2em;
}
/*
* The Box-sizing hack
*
* @link: https://w3bits.com/box-sizing-reset/
*/
*, *:before, *:after {
box-sizing: inherit;
}
/* Set the basic text properties */
body {
font: 1em/1.8 Outfit, sans-serif;
color: #444;
}
/* Add a little bit more spacing to paragraphs */
p:not(:last-child) {
margin-bottom: 1.5em;
}
/* Align the content to the center of the page */
.content {
margin-inline: auto;
max-width: 640px;
}
.content-title {
text-align: center;
}
/* Add the basic cosmetics for the pull quote */
.pulled-quote {
font-size: 1.1em;
font-weight: bold;
display: block;
text-align: center;
color: #999;
padding-block: 1em;
margin-block: 1.5em;
}
/* Add quotes to the pull quote */
.pulled-quote--quoted:before {
content: open-quote;
}
.pulled-quote--quoted:after {
content: close-quote;
}
/* Add a darker color shade to pull quote */
.pulled-quote--highlighted {
color: #111;
}
@media only screen and (min-width: 1024px) {
/*
* Add width to the pull quote except for
* when it's center-aligned
*/
.pulled-quote:not(.pulled-quote--center) {
width: 300px;
}
/*
* Add suitable spacing and alignment to the
* left and right aligned pull quotes
*/
.pulled-quote--right {
float: right;
margin: 0 -200px 0 0;
padding: 0 0 1.5em 1.5em;
text-align: left;
}
.pulled-quote--left {
float: left;
margin: 0 0 0 -200px;
padding: 0 1.5em 1.5em 0;
text-align: right;
}
}
/* Highlight the pull quote sources temporarily */
p span:not([class]) {
color: orange;
background-color: lightyellow;
}
const app = Vue.createApp({});
// Add a pull quote directive
app.directive("pq", {
mounted(el, binding) {
// Add a clone of `el` to the parent node
var elParent = el.parentNode
var elClone = el.cloneNode(true)
elParent.prepend(elClone)
/*
* Apply the `.pull-quote` CSS class to the cloned
* element.
*/
elClone.classList.add("pulled-quote")
/*
* Add the directive expression as the abbreviated
* content for the pull quote.
*/
if(binding.value) {
elClone.innerHTML = binding.value
}
/*
* Add some alignment arguments to the `v-pq`
*
* For eg. v-on:right, v-on:center. The v-on:left
* will be the default behavior of `v-pq`.
*/
switch(binding.arg) {
case 'right':
elClone.classList.add("pulled-quote--right")
break
case 'center':
elClone.classList.add("pulled-quote--center")
break
default:
elClone.classList.add("pulled-quote--left")
break
}
/*
* Add some text-formatting modifiers to the `v-pq`
*
* For eg. v-on:right.italic,
* v-on:center.highlighted.
*/
if(binding.modifiers.italic) {
elClone.style.fontStyle = "italic"
}
if(binding.modifiers.quoted) {
elClone.classList.add("pulled-quote--quoted")
}
if(binding.modifiers.highlighted) {
elClone.classList.add("pulled-quote--highlighted")
}
}
})
app.mount("#app");
Also see: Tab Triggers