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.
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Positioning</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<nav>
<ul class="nav">
<li>home</li>
<li>about</li>
<li>portfolio</li>
<li>contact</li>
</ul>
</nav>
<div class="wrapper">
<div class="top">Top</div>
<div class="middle">Middle</div>
<div class="bottom">Bottom</div>
</div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pulvinar venenatis dolor, ut iaculis libero dignissim quis. Curabitur molestie dapibus lorem mattis gravida. Proin blandit nisi ac arcu fermentum sollicitudin. Cras tempor quam eget odio vulputate sed rutrum justo lobortis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Morbi ultricies fermentum blandit. Vestibulum nisi ante, placerat id mattis a, bibendum malesuada augue.</p>
<p>Phasellus tincidunt eros id nisl ultrices ornare. Nunc sem metus, bibendum nec aliquet in, luctus non libero. Duis posuere cursus accumsan. Cras vulputate sagittis mollis. Mauris diam est, malesuada ac tempus vel, molestie ut nunc. Maecenas bibendum, elit in lacinia lobortis, dolor erat dapibus mauris, non iaculis massa augue at turpis. Suspendisse et enim in libero condimentum venenatis. Nam eleifend, lacus quis dictum blandit, eros dui eleifend nunc, ac cursus justo mauris sed nunc. In hac habitasse platea dictumst. Etiam viverra lectus sed erat tincidunt a eleifend enim eleifend. Proin pharetra tempus magna mollis tincidunt. Etiam arcu arcu, rhoncus in vestibulum a, sollicitudin a massa. Proin vitae dui sem.</p>
<p>Quisque vel neque neque. Mauris rutrum augue eget metus facilisis et laoreet tellus convallis. Vestibulum sapien risus, iaculis et blandit ac, consectetur eu elit. Nullam mattis congue tincidunt. Nam eu velit turpis, sit amet vestibulum tortor. Pellentesque dictum, eros et suscipit placerat, dolor nisi consequat odio, a dapibus urna felis nec diam. Suspendisse sem nisl, varius et facilisis vel, volutpat et purus. Praesent id metus ante, quis gravida erat. Mauris vel urna massa, at fermentum turpis. Nunc eleifend egestas nulla, vitae porta massa luctus tempor.</p>
<p>Proin ornare dapibus lectus nec tincidunt. Mauris et turpis vitae lacus pulvinar interdum et ut lectus. Integer ut convallis est. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque egestas porta nisi ut imperdiet. Nulla et sem diam. Integer ornare, velit a interdum tempor, nunc dui sodales dui, eu rhoncus nisi augue consectetur nibh. Fusce sagittis est a mauris bibendum id congue lorem posuere. Fusce lacinia metus vitae mauris vestibulum non convallis quam sollicitudin.</p>
<p>Cras sapien lectus, tincidunt in mattis vitae, cursus id ante. Donec porttitor sapien in est aliquet blandit. Aliquam tellus justo, facilisis eget pellentesque id, ultricies nec eros. Nullam neque neque, sollicitudin id consequat sed, feugiat feugiat quam. Aenean in lectus elit. Ut tristique, nulla malesuada lacinia vestibulum, purus tortor vestibulum quam, eu molestie eros tortor ac arcu. Suspendisse potenti. Nulla aliquam, sapien id adipiscing porttitor, eros dui fringilla nisi, et volutpat leo nisl sed metus. Sed dui est, placerat et mollis lobortis, vehicula eu magna. Ut a ante eget neque viverra vehicula nec vulputate eros. Etiam mi mi, vestibulum vitae sodales ac, tempor eget libero. Cras nisi dolor, commodo sed faucibus id, mattis in lectus. Sed ut augue eu nulla suscipit facilisis ac eu ipsum. Sed tincidunt luctus lobortis. Cras interdum lacinia mi, at porttitor lorem posuere qui.</p>
<p>Phasellus tincidunt eros id nisl ultrices ornare. Nunc sem metus, bibendum nec aliquet in, luctus non libero. Duis posuere cursus accumsan. Cras vulputate sagittis mollis. Mauris diam est, malesuada ac tempus vel, molestie ut nunc. Maecenas bibendum, elit in lacinia lobortis, dolor erat dapibus mauris, non iaculis massa augue at turpis. Suspendisse et enim in libero condimentum venenatis. Nam eleifend, lacus quis dictum blandit, eros dui eleifend nunc, ac cursus justo mauris sed nunc. In hac habitasse platea dictumst. Etiam viverra lectus sed erat tincidunt a eleifend enim eleifend. Proin pharetra tempus magna mollis tincidunt. Etiam arcu arcu, rhoncus in vestibulum a, sollicitudin a massa. Proin vitae dui sem.</p>
<p>Quisque vel neque neque. Mauris rutrum augue eget metus facilisis et laoreet tellus convallis. Vestibulum sapien risus, iaculis et blandit ac, consectetur eu elit. Nullam mattis congue tincidunt. Nam eu velit turpis, sit amet vestibulum tortor. Pellentesque dictum, eros et suscipit placerat, dolor nisi consequat odio, a dapibus urna felis nec diam. Suspendisse sem nisl, varius et facilisis vel, volutpat et purus. Praesent id metus ante, quis gravida erat. Mauris vel urna massa, at fermentum turpis. Nunc eleifend egestas nulla, vitae porta massa luctus tempor.</p>
<p>Proin ornare dapibus lectus nec tincidunt. Mauris et turpis vitae lacus pulvinar interdum et ut lectus. Integer ut convallis est. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque egestas porta nisi ut imperdiet. Nulla et sem diam. Integer ornare, velit a interdum tempor, nunc dui sodales dui, eu rhoncus nisi augue consectetur nibh. Fusce sagittis est a mauris bibendum id congue lorem posuere. Fusce lacinia metus vitae mauris vestibulum non convallis quam sollicitudin.</p>
</body>
</html>
.nav {
width: 100%;
background: #fff;
position: fixed;
top: -0;
color: #000;
z-index: 30;
}
.nav li {
display: inline-block;
margin: 5px 45px;
}
body {
margin: 70px 0 0;
background: #E1E1DD;
color: #FFF;
font: normal 1.4em sans-serif;
}
.wrapper {
box-sizing: border-box;
margin: 0 auto;
width: 80%;
background: #FFF;
position: relative;
}
.top {
background: #FF6347;
}
.middle {
background: #87CEEB;
position: absolute;
right: 0;
bottom: 0;
}
.middle:after {
position: absolute;
bottom: 0;
left:0;
width: 50px;
height:50px;
background:#000;
content:"";
}
.bottom {
background: #20B2AA;
}
.fixed {
position: fixed;
top: 0;
width: 100%;
height: 60px;
background-color: black;
}
.wrapper div {
width: 150px;
height: 150px;
text-align: center;
line-height: 150px;
text-shadow: 0 1px 1px rgba(0, 0, 0, .5);
}
<u>
nited than <div>
ided.
Also see: Tab Triggers