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.
<form class="topLabel">
<header class="form-header">
<h2>A Form of Fantasy</h2>
<div>"The gift of fantasy has meant more to me than my talent for absorbing positive knowledge." - Albert Einstein</div>
</header>
<ul>
<li id="form-field-1">
<fieldset>
<legend>
Which is better?
</legend>
<div>
<span>
<input id="Field1_0" name="Field1" type="radio" class="field radio" value="Fantasty" checked="checked" />
<label class="choice" for="Field1_0" >
Fantasty
</label>
</span>
<span>
<input id="Field1_1" name="Field1" type="radio" class="field radio" value="Sci-Fi" />
<label class="choice" for="Field1_1" >
Sci-Fi
</label>
</span>
<span>
<input id="Field1_2" name="Field1" type="radio" class="field radio" value="Don't make me choose!" />
<label class="choice" for="Field1_2" >
Don't make me choose!
</label>
</span>
<span>
<input id="Field1_3" name="Field1" type="radio" class="field radio" value="I don't like either" />
<label class="choice" for="Field1_3" >
I don't like either
</label>
</span>
</div>
</fieldset>
</li>
<li id="form-field-2">
<label class="desc" id="title2" for="Field2">
How much would you donate to a Kickstarter to bring back Firefly?
</label>
<span class="symbol">$</span>
<span>
<input id="Field2" name="Field2" type="text" class="field text currency nospin" value="" size="10" />
<label for="Field2">Dollars</label>
</span>
<span class="symbol radix">.</span>
<span class="cents">
<input id="Field2-1" name="Field2-1" type="text" class="field text nospin" value="" size="2" maxlength="2" />
<label for="Field2-1">Cents</label>
</span>
</li>
<li id="form-field-3" class="likert">
<table cellspacing="0">
<caption id="title3">
Rate the Star Wars movies
</caption>
<thead>
<tr>
<th> </th>
<td>Didn't Like At All</td>
<td>Meh</td>
<td>Kinda Liked</td>
<td>Loved!</td>
</tr>
</thead>
<tbody>
<tr class="statement3">
<th>
<label for="Field3">Episode I - The Phantom Menace</label>
</th>
<td title="Didn't Like At All">
<input id="Field3_1" name="Field3" type="radio" value="Didn't Like At All" />
<label for="Field3_1">1</label>
</td>
<td title="Meh">
<input id="Field3_2" name="Field3" type="radio" value="Meh" />
<label for="Field3_2">2</label>
</td>
<td title="Kinda Liked">
<input id="Field3_3" name="Field3" type="radio" value="Kinda Liked" />
<label for="Field3_3">3</label>
</td>
<td title="Loved!">
<input id="Field3_4" name="Field3" type="radio" value="Loved!" />
<label for="Field3_4">4</label>
</td>
</tr>
<tr class="alt statement4">
<th>
<label for="Field4">Episode II - Attack of the Clones</label>
</th>
<td title="Didn't Like At All">
<input id="Field4_1" name="Field4" type="radio" value="Didn't Like At All" />
<label for="Field4_1">1</label>
</td>
<td title="Meh">
<input id="Field4_2" name="Field4" type="radio" value="Meh" />
<label for="Field4_2">2</label>
</td>
<td title="Kinda Liked">
<input id="Field4_3" name="Field4" type="radio" value="Kinda Liked" />
<label for="Field4_3">3</label>
</td>
<td title="Loved!">
<input id="Field4_4" name="Field4" type="radio" value="Loved!" />
<label for="Field4_4">4</label>
</td>
</tr>
<tr class="statement5">
<th><label for="Field5">Episode III - Revenge of the Sith</label></th>
<td title="Didn't Like At All">
<input id="Field5_1" name="Field5" type="radio" value="Didn't Like At All" />
<label for="Field5_1">1</label>
</td>
<td title="Meh">
<input id="Field5_2" name="Field5" type="radio" value="Meh" />
<label for="Field5_2">2</label>
</td>
<td title="Kinda Liked">
<input id="Field5_3" name="Field5" type="radio" value="Kinda Liked" />
<label for="Field5_3">3</label>
</td>
<td title="Loved!">
<input id="Field5_4" name="Field5" type="radio" value="Loved!" />
<label for="Field5_4">4</label>
</td>
</tr>
<tr class="alt statement6">
<th>
<label for="Field6">Episode IV - A New Hope</label>
</th>
<td title="Didn't Like At All">
<input id="Field6_1" name="Field6" type="radio" value="Didn't Like At All" />
<label for="Field6_1">1</label>
</td>
<td title="Meh">
<input id="Field6_2" name="Field6" type="radio" value="Meh" />
<label for="Field6_2">2</label>
</td>
<td title="Kinda Liked">
<input id="Field6_3" name="Field6" type="radio" value="Kinda Liked" />
<label for="Field6_3">3</label>
</td>
<td title="Loved!">
<input id="Field6_4" name="Field6" type="radio" value="Loved!" />
<label for="Field6_4">4</label>
</td>
</tr>
<tr class="statement7">
<th>
<label for="Field7">Episode V - The Empire Strikes Back</label>
</th>
<td title="Didn't Like At All">
<input id="Field7_1" name="Field7" type="radio" value="Didn't Like At All" />
<label for="Field7_1">1</label>
</td>
<td title="Meh">
<input id="Field7_2" name="Field7" type="radio" value="Meh" />
<label for="Field7_2">2</label>
</td>
<td title="Kinda Liked">
<input id="Field7_3" name="Field7" type="radio" value="Kinda Liked" />
<label for="Field7_3">3</label>
</td>
<td title="Loved!">
<input id="Field7_4" name="Field7" type="radio" value="Loved!" />
<label for="Field7_4">4</label>
</td>
</tr>
<tr class="alt statement8">
<th>
<label for="Field8">Episode VI - Return of the Jedi</label>
</th>
<td title="Didn't Like At All">
<input id="Field8_1" name="Field8" type="radio" value="Didn't Like At All" />
<label for="Field8_1">1</label>
</td>
<td title="Meh">
<input id="Field8_2" name="Field8" type="radio" value="Meh" />
<label for="Field8_2">2</label>
</td>
<td title="Kinda Liked">
<input id="Field8_3" name="Field8" type="radio" value="Kinda Liked" />
<label for="Field8_3">3</label>
</td>
<td title="Loved!">
<input id="Field8_4" name="Field8" type="radio" value="Loved!" />
<label for="Field8_4">4</label>
</td>
</tr>
</tbody>
</table>
</li>
<li id="form-field-4">
<label class="desc" id="title104" for="Field104">
Are you caught up on Game of Thrones?
</label>
<div>
<select id="Field104" name="Field104" class="field select medium" tabindex="31" >
<option value="Never seen it" selected="selected">
Never seen it
</option>
<option value="Yep, totally caught up" >
Yep, totally caught up
</option>
<option value="I've seen some but I'm not caught up" >
I've seen some but I'm not caught up
</option>
</select>
</div>
</li>
<li id="form-field-5">
<label class="desc" id="title107" for="Field107">
What is your favorite Fantasty or Sci-Fi movie of all time?
</label>
<div>
<input id="Field107" name="Field107" type="text" class="field text medium" value="" maxlength="255" tabindex="32" onkeyup="" />
</div>
</li>
<li id="form-field-6" class="section">
<section>
<h3 id="title108">
Your Information
</h3>
</section>
</li>
<li id="form-field-7">
<label class="desc" id="title105" for="Field105">
Name
</label>
<span>
<input id="Field105" name="Field105" type="text" class="field text fn" value="" size="8" tabindex="33" />
<label for="Field105">First</label>
</span>
<span>
<input id="Field106" name="Field106" type="text" class="field text ln" value="" size="14" tabindex="34" />
<label for="Field106">Last</label>
</span>
</li>
<li id="form-field-8">
<label class="desc" id="title110" for="Field110">
Email
</label>
<div>
<input id="Field110" name="Field110" type="email" spellcheck="false" class="field text medium" value="" maxlength="255" />
</div>
</li>
<li id="form-field-9">
<label class="desc" id="title117" for="Field117">
Website
</label>
<div>
<input id="Field117" name="Field117" type="url" class="field text medium" value="" maxlength="255" tabindex="36" />
</div>
</li>
<li class="buttons">
<div>
<input id="saveForm" name="saveForm" class="btTxt submit"
type="submit" value="Submit"
/>
</div>
</li>
</ul>
</form>
body {
font-family: "Lucida Grande","Lucida Sans Unicode", Tahoma, sans-serif;
line-height: 1.4;
padding: 30px;
}
.form-header {
margin: 0 0 1em 0;
padding: 0 0 1em 0;
border-bottom: 1px dotted #ccc
}
.text {
font-size: 120%;
}
form ul {
padding: 0;
}
form li {
list-style: none;
padding: 0.5em;
clear: both;
overflow: hidden;
position: relative;
}
form li span {
margin: 0 .3em 0 0;
float: left;
}
form li div span {
margin: 0;
display: block;
width: 100%;
float: left;
}
label span,
.section span,
p span,
.likert span {
display: inline;
float: none;
}
form li div label,
form li span label {
font-size: 80%;
padding-top: 0.25em;
clear: both;
display: block;
}
fieldset {
display: block;
border: none;
margin: 0;
padding: 0;
}
label.desc,
legend {
font-weight: bold;
color: #222;
padding: 0 0 0.15em 0;
margin: 0 0 0.15em 0;
display: block;
}
label.choice {
display: block;
cursor: pointer;
font-size: 100%;
line-height: 150%;
margin: -1.25em 0 0 1.5em;
padding: 0 0 0.25em 0;
}
.likert table {
margin: 0 0 1em 0;
width: 100%;
border: 1px solid #dedede;
}
.likert caption {
font-weight: bold;
text-align: left;
margin: 0 0 0.5em 0;
}
.likert input {
margin: 0.25em 0;
}
.likert tbody td label {
display: block;
}
.likert thead td,
.likert thead th {
background-color: #e6e6e6
}
.likert td {
border-left: 1px solid #ccc;
text-align: center;
padding: 0.25em;
width: 100px;
}
.likert thead td {
font-size: 85%;
padding: 10px 6px;
}
.likert th,
.likert td {
border-bottom: 1px solid #dedede;
}
.likert tbody th {
padding: 8px 8px;
text-align: left;
}
.likert tbody th label {
color: #222;
font-weight: bold
}
.likert tbody tr.alt td,
.likert tbody tr.alt th {
background-color: #f5f5f5;
}
.likert tbody tr:hover td,
.likert tbody tr:hover th {
background-color:#FFFFCF;
}
form li.section {
padding: 1em 0 0 0;
}
form li.section h3 {
font-size: 110%;
line-height: 135%;
margin: 0 0 3px 0;
padding: 12px 1% 0 1%;
border-top: 1px dotted #ccc
}
Also see: Tab Triggers