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.
<h1>Form UI Styling</h1>
<form action="#">
<div>
<h2>Login</h2>
<input type="email" placeholder="Email">
<input type="password" placeholder="Password">
</div>
<div>
<label for="name">Text Input</label>
<input type="text" name="name" id="name" placeholder="John Smith" />
</div>
<fieldset class="radio-inline">
<legend>Radio Button Choice</legend>
<input type="radio" name="radio-choice" id="radio-choice-1" value="choice-1" />
<label for="radio-choice-1">
<span></span>Choice 1</label>
<input type="radio" name="radio-choice" id="radio-choice-2" value="choice-2" />
<label for="radio-choice-2">
<span></span>Choice 2</label>
<input type="radio" name="radio-choice" id="radio-choice-3" value="choice-3" />
<label for="radio-choice-3">
<span></span>Choice 3</label>
<input type="radio" name="radio-choice" id="radio-choice-4" value="choice-4" />
<label for="radio-choice-4">
<span></span>Choice 4</label>
</fieldset>
<div>
<label for="select-choice">Select Dropdown Choice:</label>
<div class="select">
<select name="select-choice" id="select-choice">
<option value="Choice 1">Choice 1</option>
<option value="Choice 2">Choice 2</option>
<option value="Choice 3">Choice 3</option>
</select>
</div>
</div>
<fieldset class="radio-list">
<legend>Radio Button List Choice</legend>
<input type="radio" name="radio-choice-list" id="radio-choice-list-1" value="choice-list-1" />
<label for="radio-choice-list-1">
<span></span>
<strong>A:</strong> There Title Total Trust Tsena</label>
<input type="radio" name="radio-choice-list" id="radio-choice-list-2" value="choice-list-2" />
<label for="radio-choice-list-2">
<span></span>
<strong>B:</strong> Llama Lorrie Lt. Lucy Lyle Madeira Mechanic</label>
<input type="radio" name="radio-choice-list" id="radio-choice-list-3" value="choice-list-3" />
<label for="radio-choice-list-3">
<span></span>
<strong>C:</strong> Eden Eerie Effingham, Il. Egypt Eiffel</label>
<input type="radio" name="radio-choice-list" id="radio-choice-list-4" value="choice-list-4" />
<label for="radio-choice-list-4">
<span></span>
<strong>D:</strong> Guinevere Gwathmey Gypsy Gzags Hebrew</label>
</fieldset>
<div>
<label for="textarea">Textarea</label>
<textarea cols="40" rows="8" name="textarea" id="textarea"></textarea>
</div>
<div class="agreement">
<p>Br. Guinevere Gwathmey Gypsy Gzags Hebrew Hf Hg Hileah Horace Hrdlicka Hsia Hts. Hubert Hwang Hai Hyacinth Hz. Iaccoca Ibsen Iceland Idaho If Iggy Ihre Ijit Ike Iliad Immediate Innocent Ione Ipswitch Iquarus Ireland Island It Iud Ivert Iwerks Ixnay Iy Jasper Jenks Jherry Jill Jm Jn Jorge Jr. Julie Kerry Kharma Kiki Klear Koko Kruse Kusack Kylie Laboe Lb. Leslie Lhihane Llama Lorrie Lt. Lucy Lyle Madeira Mechanic Mg. Minnie Morrie Mr. Ms. Mt. Music My Nanny Nellie Nillie Novocane Null Nyack Oak Oblique Occarina Odd Oedipus Off Ogmane Ohio Oil Oj Oklahoma Olio Omni Only Oops Opera Oqu Order Ostra Ottmar Out Ovum Ow Ox Oyster Oz Parade Pd. Pepe Pfister Pg. Phil Pippi Pj Please Pneumonia Porridge Price Psalm Pt. Purple Pv Pw Pyre Qt. Quincy Radio Rd. Red Rhea Right Rj Roche Rr Rs Rt. Rural Rwanda Ryder Sacrifice Series Sgraffito Shirt Sister Skeet Slow Smore Snoop Soon Special Squire Sr St. Suzy Svelte Swiss Sy Szach Td Teach There Title Total Trust Tsena Tulip Twice Tyler Tzean Ua Udder Ue Uf Ugh Uh Ui Uk Ul Um Unkempt Uo Up Uq Ursula Use Utmost Uvula Uw Uxurious Uzßai Valerie Velour Vh Vicky Volvo Vs Water Were Where With World Wt. Wulk Wyler Xavier Xerox Xi Xylophone Yaboe Year Yipes Yo Ypsilant Ys Yu Zabar’s Zero Zhane Zizi Zorro Zu Zy Don’t I’ll I’m I’se</p>
<p>Aaron Abraham Adam Aeneas Agfa Ahoy Aileen Akbar Alanon Americanism Anglican Aorta April Fool’s Day Aqua Lung (Tm.) Arabic Ash Wednesday Authorized Version Ave Maria Away Axel AyAztec Bhutan Bill Bjorn Bk Btu. Bvart Bzonga California Cb Cd Cervantes Chicago Clute City, Tx. Cmdr. Cnossus Coco Cracker State, Georgia Cs Ct. Cwacker Cyrano David Debra Dharma Diane Djakarta Dm Dnepr Doris Dudley Dwayne Dylan Dzerzhinsk Eames Ectomorph Eden Eerie Effingham, Il. Egypt Eiffel Tower Eject Ekland Elmore Entreaty Eolian Epstein Equine Erasmus Eskimo Ethiopia Europe Eva Ewan Exodus Jan van Eyck Ezra Fabian February Fhara Fifi Fjord Florida Fm France Fs Ft. Fury Fyn Gabriel Gc Gdynia Gehrig Ghana Gilligan Karl Gjellerup Gk. Glen Gm Gnosis Gp.E. Gregory Gs Gt.</p>
<p>Br. Guinevere Gwathmey Gypsy Gzags Hebrew Hf Hg Hileah Horace Hrdlicka Hsia Hts. Hubert Hwang Hai Hyacinth Hz. Iaccoca Ibsen Iceland Idaho If Iggy Ihre Ijit Ike Iliad Immediate Innocent Ione Ipswitch Iquarus Ireland Island It Iud Ivert Iwerks Ixnay Iy Jasper Jenks Jherry Jill Jm Jn Jorge Jr. Julie Kerry Kharma Kiki Klear Koko Kruse Kusack Kylie Laboe Lb. Leslie Lhihane Llama Lorrie Lt. Lucy Lyle Madeira Mechanic Mg. Minnie Morrie Mr. Ms. Mt. Music My Nanny Nellie Nillie Novocane Null Nyack Oak Oblique Occarina Odd Oedipus Off Ogmane Ohio Oil Oj Oklahoma Olio Omni Only Oops Opera Oqu Order Ostra Ottmar Out Ovum Ow Ox Oyster Oz Parade Pd. Pepe Pfister Pg. Phil Pippi Pj Please Pneumonia Porridge Price Psalm Pt. Purple Pv Pw Pyre Qt. Quincy Radio Rd. Red Rhea Right Rj Roche Rr Rs Rt. Rural Rwanda Ryder Sacrifice Series Sgraffito Shirt Sister Skeet Slow Smore Snoop Soon Special Squire Sr St. Suzy Svelte Swiss Sy Szach Td Teach There Title Total Trust Tsena Tulip Twice Tyler Tzean Ua Udder Ue Uf Ugh Uh Ui Uk Ul Um Unkempt Uo Up Uq Ursula Use Utmost Uvula Uw Uxurious Uzßai Valerie Velour Vh Vicky Volvo Vs Water Were Where With World Wt. Wulk Wyler Xavier Xerox Xi Xylophone Yaboe Year Yipes Yo Ypsilant Ys Yu Zabar’s Zero Zhane Zizi Zorro Zu Zy Don’t I’ll I’m I’se</p>
</div>
<div class="checkbox">
<!-- <legend>Check All That Apply</legend> -->
<input type="checkbox" name="checkbox" id="checkbox" />
<label for="checkbox">
<span>Checkbox</span>
</label>
</div>
<div>
<input type="submit" value="Submit" />
</div>
</form>
@import "compass/css3";
@import "compass/css3";
// Form Variables
// --------------------
$font-size: 1em;
$selected-color: violet;
$dark-gray: darkslategray;
$corner-radius: .3em;
$corner-radius-sharp: .25em;
// Remove Moz border
::-moz-focus-inner {
border: 0;
}
*::selection {
background-color: rgba($selected-color,.8);
}
// Mixins
// --------------------
@mixin transition-fix {
-webkit-transform: translatez(0);
-moz-transform: translatez(0);
-ms-transform: translatez(0);
-o-transform: translatez(0);
transform: translatez(0);
}
@mixin input-box() {
@include box-sizing(border-box);
-moz-box-sizing: border-box;
padding: .5em 1em;
border: none;
border-radius: $corner-radius;
background: #eee;
// Removes styling on Safari: --webkit-appearance and Mozilla: --moz-appearance
&:focus {
@include box-shadow(rgba(black, 0.05) 0 0 10px 1px inset);
box-sizing: border-box;
outline: none;
background: #f3f3f3;
}
}
@mixin input-text() {
font-size: 1em;
font-family: 'Helvetica Neue', helvetica, sans-serif;
line-height: 1.5em;
&:focus {
color: $dark-gray;
}
}
@mixin input-highlight() {
@include transition(border, 100ms);
&:focus {
border-left: .5em solid $selected-color;
}
}
@mixin input-style() {
@include input-highlight;
@include input-text;
@include input-box;
}
// --------------------
body {
background: #eee;
color: $dark-gray;
font-family: 'Helvetica Neue', helvetica, sans-serif;
}
h1 {
text-align: center;
font-weight: 100;
font-size: 3em;
margin: 1em 0;
}
form {
margin: 4em auto;
padding: 1em;
max-width: 640px;
background: white;
border-radius: $corner-radius-sharp;
}
legend {
display: block;
margin: 0 auto;
// width: 100%;
}
label {
display: inline-block;
margin: .5em 0;
}
input {
@include input-style;
display: block;
margin: .5em 0;
}
input[type="email"],
input[type="password"] {
width: 50%;
}
// Text Input
// --------------------
input[type="text"] {
width: 100%;
}
// Radios
// --------------------
fieldset {
margin: 1em 0;
padding: 1em;
border: #f3f3f3 solid 2px;
border-radius: $corner-radius;
text-align: center;
// Radio List
// --------------------
&.radio-list {
text-align: left;
& input[type="radio"] + label {
display: block;
}
}
input[type="radio"] {
position: absolute;
// display: none;
opacity: 0;
}
input[type="radio"] + label {
margin-right: 1em;
color: #999;
cursor: pointer;
}
input[type="radio"]:focus + label,
input[type="radio"]:hover + label,
input[type="radio"] + label:hover,
input[type="radio"]:checked + label {
color: $dark-gray;
}
input[type="radio"] + label span {
display: inline-block;
box-sizing: border-box;
-moz-box-sizing: border-box;
margin-right: .25em;
width: 1em;
height: 1em;
border: .25em solid #ccc;
border-radius: 50%;
vertical-align: text-bottom;
transition: border, 200ms;
}
input[type="radio"]:focus + label span,
input[type="radio"] + label:hover span,
input[type="radio"] + label span:hover {
border: .25em solid $dark-gray;
}
input[type="radio"]:checked + label span {
border: .25em solid $selected-color;
background-color: $dark-gray;
}
}
// Select
// --------------------
.select {
position: relative;
width: 50%;
@include box-sizing(border-box);
-moz-box-sizing: border-box;
border: none;
border-radius: $corner-radius;
background: #eee;
// Removes styling on Safari: --webkit-appearance and Mozilla: --moz-appearance
&:focus {
@include box-shadow(rgba(black, 0.05) 0 0 10px 1px inset);
box-sizing: border-box;
outline: none;
background: #f3f3f3;
}
// This prevents clicking the select
&:after {
@include rotate(-45deg);
position: absolute;
right: 1em;
bottom: 40%;
display: block;
width: .75em;
height: .75em;
border: 2px solid $dark-gray;
border-top: none;
border-right: none;
content: '';
}
&:focus,
&:hover:after {
border: 4px solid $selected-color;
border-top: none;
border-right: none;
transition: border, 100ms;
}
select {
@include appearance(none);
@include input-style;
background: transparent;
z-index: 1;
position: relative;
display: block;
width: 100%;
outline: none;
border: none;
font-size: 100%;
&:focus {
background: transparent;
}
// Not working...
&:focus + .select:after {
border: 4px solid $selected-color;
border-top: none;
border-right: none;
transition: border, 100ms;
}
}
}
// Text Area
// --------------------
textarea {
@include input-style;
display: block;
// min-height: 100%;
width: 100%;
min-width: 100%;
max-width: 100%;
}
// Licence Text
// --------------------
.agreement {
margin: 1em 0;
box-sizing: border-box;
-moz-box-sizing: border-box;
padding: 1em;
border-radius: $corner-radius;
background: #eee;
overflow: scroll;
max-height: 16em;
p {
margin: 1em 0;
font-size: .625em;
line-height: 1.2;
color: #999;
}
}
// Checkbox
// --------------------
input[type=checkbox] {
margin: 0;
width: 20px;
height: 20px;
opacity: 0;
//visibility: hidden;
}
.checkbox {
position: relative;
clear: both;
margin: 1em 0;
text-align: left;
& label {
position: absolute;
top: 0;
left: 0;
margin: 0;
width: 20px;
height: 20px;
border-radius: $corner-radius;
background: #eee;
cursor: pointer;
}
& label:after {
@include opacity(0);
@include rotate(-45deg);
position: absolute;
bottom: .6em;
left: 25%;
width: 0;
height: 0;
border: 2px solid #333;
border-top: none;
border-right: none;
background: transparent;
content: '';
transition: width, height, border, 100ms;
}
& label:hover,
& input[type=checkbox]:checked + label {
@include box-shadow(rgba(black, 0.05) 0 0 10px 1px inset);
}
& input[type=checkbox]:focus + label:after,
& label:hover:after {
@include opacity(.5);
width: 1em;
height: 8px;
}
& input[type=checkbox]:checked + label:after {
@include opacity(1);
width: 1em;
height: .6em;
border: 4px solid $selected-color;
border-top: none;
border-right: none;
}
& span {
margin-left: 2em;
line-height: 20px;
}
}
// Submit Button
// --------------------
input[type="submit"] {
@include transition-property(background-color, color);
@include transition-duration(200ms);
display: block;
margin: 0 auto;
padding: .5em 2em;
width: 50%;
border: none;
border-radius: $corner-radius;
background-color: $dark-gray;
color: white;
font-size: 1em;
// Removes styling on Safari: --webkit-appearance and Mozilla: --moz-appearance
&:hover, &:active, &:focus {
background-color: $selected-color;
color: black;
}
}
Also see: Tab Triggers