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.
You are linking to a resource using the non-secure http:// protocol, which may not work when the browser is using https:// like CodePen enforces.
When linking another Pen as a resource, make sure you use a URL Extension of the type of code you want to link to. Either .css
, .js
, or the extension of a matching code processor.
You are linking to a resource using the non-secure http:// protocol, which may not work when the browser is using https:// like CodePen enforces.
When linking another Pen as a resource, make sure you use a URL Extension of the type of code you want to link to. Either .css
, .js
, or the extension of a matching code processor.
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.
You are linking to a resource using the non-secure http:// protocol, which may not work when the browser is using https:// like CodePen enforces.
When linking another Pen as a resource, make sure you use a URL Extension of the type of code you want to link to. Either .css
, .js
, or the extension of a matching code processor.
You are linking to a resource using the non-secure http:// protocol, which may not work when the browser is using https:// like CodePen enforces.
When linking another Pen as a resource, make sure you use a URL Extension of the type of code you want to link to. Either .css
, .js
, or the extension of a matching code processor.
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.
Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.
Upgrade to PROIf 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.
Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.
Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:
Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.
This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.
Upgrade to PRO
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Doraemon Fan Page</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Welcome to the Doraemon Fan Page!</h1>
<h2>All About Doraemon</h2>
<p><strong>Doraemon</strong> is a famous robot cat from the future. He helps <em>Nobita</em> with gadgets from his four-dimensional pocket. Explore more about <a href="#more-info">Doraemon's adventures</a>!</p>
​
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAJQAlgMBIgACEQEDEQH/xAAbAAEAAgMBAQAAAAAAAAAAAAAABgcBBAUDAv/EAEQQAAEDAwIDBAYFCgMJAAAAAAECAwQABRESIQYxQRNRYXEHFCIygaEjQnKRsSQlM1JigqKywcIVY5IWNDVDU3TS4eL/xAAaAQEBAAMBAQAAAAAAAAAAAAAABAECAwUG/8QALBEAAgIBAwMCBAcBAAAAAAAAAAECAxEEEjEhIjJBUVJxobEFFDNCYZHwE//aAAwDAQACEQMRAD8AvGmaVg86AZpmo3xdxWzw8zp7FbsxxOWW9CtKznGNQHPw513Ybq34jLrrRacWgKU2TnSSOVYTy8G7rmoKbXRmxSg5UrJoKxms1x7rxJarSrs5ktPbYz2LY1r+4cvjWUm+DDeDsUzUEf8ASTDCiI0B5YzgKccSgE/DNeJ9I60e05a0BPf6z/8ANdFRY+EaO2C5ZYNKh0T0hW1xSUTYsyIVciprUD5Y3+VSa33KHcmQ9BktPt/rNqzjwPdXNxkuUb7kbdKUrBkUpSgFKUoBSlKAVg1msUBxeIr9arKI/wDiisdso9n9GVbjr4YyK4XA3E9xv90uKJLbfqje7RQnGjfZJPXbepbcLdEuLBZnR232j9Vac48u6vi1WmFaI3q1uYSy1kqIT1PeT1rTD3Zz0Ko2Uqhxcczfr6I3Ry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J7FwDJSQMZ8dsgjxNayunJ5bNlXBLCRXznAN8T+iet7g7y6tH9pr4TwHfyRqNuA7/WFn+yrCTMms+zJt63P82MoKSfgSFD5+dfRuaBziTfhHUa6fmrfc0dEPYjXDfCNwsklc4T4zkgtFsNdirQUkg4znOcgb4+FS2DJTLjIdCSknIUkndKgcEfAgitVVyWsYjQJbjnIBbfZp+JV08snwr3t0dcaMEOqCnVKUtxQ5alEqOPDJrjKTk8s6pJLCNulKVqZFKUoBSlKAUpSgFKUoBSlKAUpSgFKUoBSlKAUpSgFKUoBSlKAUpSgFKUoBWDSlAeEd1TqVlQA0uqRt3A19pWSojbl/WlKALOkZHlXzJdU0kFON1oTv3FQH9aUoD7BJyPGs5NYpQGlPmOR5kVlCUFLwc1ahuNKcjFctq/Slpjkts/Sw3X1YSfeSdhz5UpQHs5eZCWpCghrLcRD42PvKJBHPlWm/wARzEKuIDTB9VWhKMpVuCQDnelKA6s2e6y+htCUYVLbZJIOdKk5J5866qfdFKUBmlKUApSlAf/Z" alt="Doraemon" class="doraemon-img">
​
<button id="fun-button">Click Me!</button>
​
<hr>
<div id="more-info">
​
xxxxxxxxxx
​
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background: linear-gradient(to right, #87CEEB, #FFFFFf);
text-align: center;
color: #333;
}
​
.container {
margin-top: 50px;
}
​
h1 {
font-size: 3em;
font-weight: bold;
color: blue;
}
​
h2 {
font-size: 2em;
font-weight: normal;
color: red;
}
​
p {
font-size: 1.2em;
line-height: 1.5;
margin: 0 20px;
}
​
a {
color: #00BFFF;
text-decoration: none;
}
​
a:hover {
text-decoration: underline;
}
xxxxxxxxxx
​
// Event listener for button click
let button = document.getElementById('fun-button');
​
button.addEventListener('click', function() {
let userName = prompt("What's your name?");
if (userName) {
alert("Hi " + userName + ", welcome to the world of Doraemon!");
}
});
​
​
Also see: Tab Triggers