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 class="container">
<header id="header">
<!-- this area is empty, because, since it has the id #header, it gets filled by the sitewide static javascript -->
</header>
<div class="main-content">
<aside id="sidebar">
<!-- this area is empty, because, since it has the id #sidebar, it gets filled by the sitewide static javascript -->
</aside>
<section>
<!-- this is the area where the main content lives, see? not much else actually in the html body section -->
<h2>Blue (Da Ba Dee)</h2>
<blockquote>
<p>Yo, listen up here's a story<br />About a little guy<br />That lives in a blue world<br />And all day and all night<br />And everything he sees is just blue<br />Like him inside and outside<br />Blue his house<br />With a blue little window<br />And a blue corvette<br />And everything is blue for him<br />And himself and everybody around<br />Cause he ain't got nobody to listen to<br />I'm blue<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />I'm blue<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba diI have a blue house<br />With a blue window<br />Blue is the colour of all that I wear<br />Blue are the streets<br />And all the trees are too<br />I have a girlfriend and she is so blue<br />Blue are the people here<br />That walk around<br />Blue like my corvette its in and outside<br />Blue are the words I say<br />And what I think<br />Blue are the feelings<br />That live inside meI'm blue<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />I'm blue<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba diI have a blue house<br />With a blue window<br />Blue is the colour of all that I wear<br />Blue are the streets<br />And all the trees are too<br />I have a girlfriend and she is so blue<br />Blue are the people here<br />That walk around<br />Blue like my corvette, its in and outside<br />Blue are the words I say<br />And what I think<br />Blue are the feelings<br />That live inside me<br />I'm blue<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />I'm blue<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di<br />Da ba dee da ba di</p>
</blockquote>
</section>
</div>
<footer id="footer">
<!-- this area is empty, because, since it has the id #header, it gets filled by the sitewide static javascript -->
</footer>
</div>
</body>
</html>
/* guess what? nothing here is really important, it's just styling that makes this particular pen look delightfully europop-worthy, i hope. this trick works all on its own, without any CSS whatsoever. try removing all the css. just try it. the content, including all sitewide static content from the javascript, will still appear - it will just look silly and naked */
@import url("https://fonts.googleapis.com/css2?family=Jaro:opsz@6..72&family=Source+Code+Pro:ital,wght@0,200..900;1,200..900&display=swap");
body {
font-family: "Source Code Pro", monospace;
margin: 0;
padding: 0;
background-color: #34e3fd;
text-shadow: 0px 0px 3px #34e3fd;
}
.container {
display: flex;
width: 80%;
border: 5px solid #643cf0;
margin: 1em auto;
border-radius: 5rem;
overflow: hidden;
flex-direction: column;
min-height: 100vh;
}
header {
background: linear-gradient(145deg, #347ffd, #643cf0);
padding: 1rem;
border-bottom: 5px solid #643cf0;
text-align: center;
}
header h1 {
margin: 0;
font-family: Jaro;
font-size: 4rem;
letter-spacing: 0.8rem;
color: #34fdf5;
text-shadow: 1px 2px 2px #34e3fd, 0px 7px 5px rgba(0, 0, 0, 0.15),
0px 12px 1px rgba(0, 0, 0, 0.1), 0px 17px 15px rgba(0, 0, 0, 0.1);
}
aside h2 {
margin: 0;
font-family: Jaro;
font-size: 2rem;
letter-spacing: 0.4rem;
}
section h2 {
margin: 0;
font-family: Jaro;
font-size: 2rem;
letter-spacing: 0.4rem;
color: #5028dc;
text-shadow: 1px 3px 3px #34e3fd, 0px 7px 5px rgba(0, 0, 0, 0.15),
0px 12px 1px rgba(0, 0, 0, 0.1), 0px 17px 15px rgba(0, 0, 0, 0.1);
}
nav ul {
list-style: none;
padding: 0;
}
nav ul li {
display: inline;
margin-right: 10px;
}
nav ul li a {
text-decoration: none;
color: #a8d9f7;
font-weight: bold;
padding: 0.2rem 0.8rem;
border-radius: 5px;
box-shadow: 1px 1px 10px #34e3fd;
transition: all 1s ease;
}
nav ul li a:hover {
background-color: #34fdf5;
color: #5028dc;
}
.main-content {
display: flex;
flex: 1;
background-color: #a8d9f7;
}
aside {
background: #643cf0;
color: #a8d9f7;
padding: 1rem;
width: 25%;
}
section {
flex: 1;
padding: 1rem;
}
footer {
background: #6666f6;
text-align: center;
font-size: 1.2rem;
background: linear-gradient(145deg, #347ffd, #643cf0);
color: #a8d9f7;
border-top: 5px solid #643cf0;
padding: 0.5rem;
}
//the javascript below would need to go into its own file, and be linked at the bottom of every single page which will contain these sitewide static components. the eurodance-themed example you see here uses three of these, one for the header, one for the sidebar, and one for the footer; however, you can have as many as you need. just copy and paste what's already there and change the values and element ID that you'd like to fill.
const header = // here below is the contents of the header, including both the mock navigation and the <h1> title.
'<h1>NOW LISTEN UP</h1><nav><ul><li><a href="#">I\'m Blue</a></li><li><a href="#">Da</a></li><li><a href="#">Ba</a></li><li><a href="#">Dee</a></li><li><a href="#">About Me</a></li></ul></nav>';
document.getElementById("header").innerHTML = header;
const sidebar = // here below is the contents of the sidebar, which is just a little blurb about eiffel 65 for demonstration purposes.
'<h2>Courtesy Eiffel 65...</h2><p>I know almost nothing about Eurodance as a genre. I do, however, know that Eiffel 65\'s seminal hit, "Blue," released on their album "Europop" in 1999 changed the lives of certain middle schoolers forever, myself included. Pouring over the lyrics, seeking secret meanings, giggling and making up our own... riveting stuff...</p>';
document.getElementById("sidebar").innerHTML = sidebar;
const footer = // here below is the contents of the footer, again, mostly just for demonstration. remember - while this particular pen features just these three areas (a header, sidebar, and footer), you can have as many as you need, really)
"<p>Surely it did have <em>some</em> kind of secret or hidden meaning of some sort, right? Let's be reasonable...</p>";
document.getElementById("footer").innerHTML = footer;
Also see: Tab Triggers