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.
<!-- bubble introducing a scene -->
<div class="bubble">
Alright people, let's do <strong>this one last time.</strong>
</div>
<!-- bubble highlighting something -->
<div class="bubble bubble--highlight">
Play dumb
</div>
<!-- tag with the name of the main character -->
<div class="tag">
<strong>Hello</strong>
<br />
my name is
</div>
@import url("https://fonts.googleapis.com/css?family=Dekko|Lato:900|Rock+Salt");
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
min-height: 100vh;
width: 100%;
background: #eee;
/* center the content in the page (mainly horizontally) */
display: grid;
place-items: center;
/* include the same texture used for the .bubble containers, but with notably less opacity */
background: url('data:image/svg+xml;utf8,<svg width="100" height="100" transform="rotate(0)" opacity="0.2" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><g fill="%23250E17"><circle cx="25" cy="25" r="12.5"/><circle cx="75" cy="75" r="12.5"/><circle cx="75" cy="25" r="12.5"/><circle cx="25" cy="75" r="12.5"/></g></svg>'),
#c52754;
background-size: 10px, 100%;
}
/* .bubble containers: add the texture above a solid background */
.bubble {
/* cap the width */
max-width: 500px;
/* give ample whitespace around and inside of the container */
margin: 2rem 0;
padding: 0.2rem 1.25rem;
text-align: center;
font-family: "Dekko", cursive;
text-transform: uppercase;
font-size: 2rem;
letter-spacing: 0.2rem;
background: url('data:image/svg+xml;utf8,<svg width="100" height="100" transform="rotate(25)" opacity="0.3" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><g fill="%23250E17"><circle cx="25" cy="25" r="12.5"/><circle cx="75" cy="75" r="12.5"/><circle cx="75" cy="25" r="12.5"/><circle cx="25" cy="75" r="12.5"/></g></svg>'),
#fff;
background-size: 12px, 100%;
/* solid border */
border: 0.4rem solid #000;
/* position relative for the :before pseudo element */
position: relative;
}
/* for the highlight container change the solid backgorund to a yellow-ish hue */
.bubble--highlight {
background: url('data:image/svg+xml;utf8,<svg width="100" height="100" transform="rotate(25)" opacity="0.8" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><g fill="%23d68810"><circle cx="25" cy="25" r="12.5"/><circle cx="75" cy="75" r="12.5"/><circle cx="75" cy="25" r="12.5"/><circle cx="25" cy="75" r="12.5"/></g></svg>'),
#ffcd28;
background-size: 13px, 100%;
font-weight: 700;
}
/* for the highlight container always add an exclamation point */
.bubble--highlight:after {
content: "!";
}
/* for every .bubble container add a solid background behind the container itself, slightly offset */
.bubble:before {
content: "";
position: absolute;
left: -1rem;
top: 0.15rem;
width: 100%;
height: 100%;
/* with the same texture, but different color, for both the texture and the background */
background: url('data:image/svg+xml;utf8,<svg width="100" height="100" transform="rotate(35)" opacity="1" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><g fill="%23250E17"><circle cx="25" cy="25" r="12.5"/><circle cx="75" cy="75" r="12.5"/><circle cx="75" cy="25" r="12.5"/><circle cx="25" cy="75" r="12.5"/></g></svg>'),
#000;
background-size: 12px, 100%;
border: 0.4rem solid #000;
z-index: -5;
}
/* for the tag, add a lot of whitespace below the string, to include the name through the pseudo element */
.tag {
margin-bottom: 2rem;
padding: 1rem 7.5rem 11rem;
border-radius: 30px;
font-size: 2rem;
color: #fff;
background: #f8012d;
text-align: center;
font-family: "Lato", sans-serif;
box-shadow: 0 1px 15px -7.5px #000000;
/* position relative for the pseudo element(s) */
position: relative;
}
.tag strong {
text-transform: uppercase;
font-size: 3.5rem;
}
/* with the :before pseudo element include a solid white background */
.tag:before {
content: "";
position: absolute;
top: 9rem;
left: 2%;
width: 96%;
height: 9rem;
background: #fff;
/* border-radius mathing the .tag container */
border-radius: 0 0 30px 30px;
}
/* with the :after pseudo element add the name of the character */
.tag:after {
content: "Peter Parker";
position: absolute;
top: 11.25rem;
left: 0;
width: 100%;
text-align: center;
font-family: "Rock Salt", cursive;
font-size: 2rem;
letter-spacing: 0.25rem;
font-weight: 300;
font-weight: bold;
color: #000;
}
// no JavaScript this time either
Also see: Tab Triggers