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 URL's 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 it's URL and the proper URL extention.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
<header>
<h1>Welcome to my site!</h1>
<nav role='navigation'>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Clients</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</nav>
</header>
<div role="main">
<article>
<h3>Cats are awesome!</h3>
<div>Omnis necessitatibus repudiandae suscipit eos itaque perspiciatis quisquam magnam deserunt doloribus iste ab at maiores unde quod consequuntur odio quas? Aut neque rerum soluta aliquid consequuntur provident itaque numquam voluptatibus.</div>
<img src="http://placekitten.com/300/200" alt="a kitten" />
</article>
<article>
<h3>Links are super cool</h3>
<div>Nisi doloremque expedita distinctio <a href="#">eos praesentium dolorem</a> facilis autem? </div>
<h4>Reasons I like links:</h4>
<ul>
<li>Morbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequat.</li>
<li>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus.</li>
<li>Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi.</li>
<li>Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.</li>
</ul>
</article>
<article>
<h3>Other Things I love, and stuff about them</h3>
<dl>
<dt>Definition list</dt>
<dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.</dd>
<dt>Lorem ipsum dolor sit amet</dt>
<dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.</dd>
</dl>
</article>
<article>
<h3>My Goals</h3>
<ol>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
<li>Vestibulum auctor dapibus neque.</li>
</ol>
</article>
</div>
<aside>
<h3>Contact Us!</h3>
<form action="#">
<div>
<label for="name">Your name:</label>
<input type="text" name="name" id="name" placeholder="John Smith" required />
</div>
<fieldset>
<legend>Favorite Post</legend>
<label for="radio-choice-1">Cats</label>
<input type="radio" name="radio-choice" id="radio-choice-1" value="choice-1" />
<label for="radio-choice-2">Links</label>
<input type="radio" name="radio-choice" id="radio-choice-2" value="choice-2" />
</fieldset>
<div>
<label for="select-choice">Reason you like Cats</label>
<select name="select-choice" id="select-choice">
<option value="Choice 1">cute</option>
<option value="Choice 2">I hate cats</option>
<option value="Choice 3">all of the above</option>
</select>
</div>
<div>
<label for="textarea">Message:</label>
<textarea cols="40" rows="8" name="textarea" id="textarea"></textarea>
</div>
<div>
<label for="checkbox">Do you like pizza?</label>
<input type="checkbox" name="checkbox" id="checkbox" />
</div>
<div>
<label for="rating">Rate Your Service (1-10)</label>
<input type="range" name="rating" id="rating" min=1 max=11 />
</div>
<div>
<input type="submit" value="Send!" />
</div>
</form>
</aside>
<footer>
Copyleft 2013 The Internet
</footer>
* {
box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
background: black;
color: white;
}
h1 {
color: rgba(255, 255, 255, .6);
text-shadow: 0 0 30px green;
text-align: center;
}
nav ul {
list-style: none;
display: flex;
}
nav li {
display: inline;
text-align: center;
margin: auto;
padding: 1em 2em;
border: 1px solid green;
border-radius: 2em;
box-shadow: inset 0 0 1em green;
}
nav li:hover {
box-shadow: inset 0 0 2em green;
}
nav li a {
text-decoration: none;
display: block;
height: 100%;
}
a {
color: green;
}
div[role="main"] {
width: 65%;
float: left;
}
aside {
width: 30%;
float: left;
background: black;
box-shadow: 0 0 5px green;
}
textarea {
width: 100%;
background: black;
box-shadow: 0 0 6px green;
margin: 12px 0;
font-family: Consolas, monospace;
color: white;
border: none;
}
article {
width: 90%;
box-shadow: 0 0 5px green;
margin: 1em auto;
padding: 1em;
}
label, input, select {
display: block;
width: 90%;
margin: .5em auto;
}
label {
margin-bottom: .3em;
}
input, select {
border-radius: .5em;
padding: .5em;
color: green;
}
input[type=submit] {
color: white;
background: green;
border: none;
}
input[type=checkbox] {
float: left;
}
input[type='range'] {
-webkit-appearance: none;
background: green;
height: .5em;
position: relative;
border-radius: 3px;
margin: 1em auto 2em auto;
}
input[type='range']::-webkit-slider-thumb {
-webkit-appearance: none;
background-color: white;
box-shadow: 1px 1px 8px pink;
width: 2em;
height: 2em;
border-radius: 50%;
position: relative;
z-index: 100;
}
input[type='range']::-webkit-slider-thumb:hover {
background: hotpink;
}
footer {
display: block;
clear: both;
text-align: center;
height: 4em;
margin: 1em auto -2em auto;
box-shadow: 0 0 10px green;
padding: 1.5em;
}
@media only screen and (max-width: 720px) {
aside, div[role="main"] {
float: none;
width: 95%;
display: block;
margin: 1em auto;
}
}
Also see: Tab Triggers