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">
<div class="control-group">
<h1>Checkboxes</h1>
<label class="control control--checkbox">First checkbox
<input type="checkbox" checked="checked"/>
<div class="control__indicator"></div>
</label>
<label class="control control--checkbox">Second checkbox
<input type="checkbox"/>
<div class="control__indicator"></div>
</label>
<label class="control control--checkbox">Disabled
<input type="checkbox" disabled="disabled"/>
<div class="control__indicator"></div>
</label>
<label class="control control--checkbox">Disabled & checked
<input type="checkbox" disabled="disabled" checked="checked"/>
<div class="control__indicator"></div>
</label>
</div>
<div class="control-group">
<h1>Radio buttons</h1>
<label class="control control--radio">First radio
<input type="radio" name="radio" checked="checked"/>
<div class="control__indicator"></div>
</label>
<label class="control control--radio">Second radio
<input type="radio" name="radio"/>
<div class="control__indicator"></div>
</label>
<label class="control control--radio">Disabled
<input type="radio" name="radio2" disabled="disabled"/>
<div class="control__indicator"></div>
</label>
<label class="control control--radio">Disabled & checked
<input type="radio" name="radio2" disabled="disabled" checked="checked"/>
<div class="control__indicator"></div>
</label>
</div>
<div class="control-group">
<h1>Select boxes</h1>
<div class="select">
<select>
<option>First select</option>
<option>Option</option>
<option>Option</option>
</select>
<div class="select__arrow"></div>
</div>
<div class="select">
<select>
<option>Second select</option>
<option>Option</option>
<option>Option</option>
</select>
<div class="select__arrow"></div>
</div>
<div class="select">
<select disabled="disabled">
<option>Disabled</option>
<option>Option</option>
<option>Option</option>
</select>
<div class="select__arrow"></div>
</div>
</div>
</div>
$color--white = #FFFFFF
$color--black = #000000
$color--light-grey = #E6E6E6
$color--grey = #CCCCCC
$color--dark-grey = #7B7B7B
$color--primary = #2AA1C0
$color--secondary = #0E647D
html, body
height 100%
body
background $color--light-grey
font-family 'Source Sans Pro', sans-serif
.container
width 100%
height 100%
display flex
flex-wrap wrap
justify-content center
align-items center
h1
font-family 'Alegreya Sans', sans-serif
font-weight 300
margin-top 0
// Box to contain form controls
.control-group
display inline-block
vertical-align top
background $color--white
text-align left
box-shadow 0 1px 2px rgba(0, 0, 0, 0.1)
padding 30px
width 200px
height 210px
margin 10px
// Basic control styles
.control
display block
position relative
padding-left 30px
margin-bottom 15px
cursor pointer
// Hide default browser input
input
position absolute
z-index -1
opacity 0
// Custom control
.control__indicator
position absolute
top 0px
left 0
height 16px
width 16px
background #fff
border 1px solid #ccc
.control--checkbox &
border-radius 3px
.control--radio &
border-radius 50% // Makes radio buttons circlular
// Hover and focus
.control:hover input:not([disabled]) ~ &,
.control input:focus ~ &
border-color: #666
// Checked
.control input:checked ~ &
background #fff
// Hover when checked
/*
.control:hover input:not([disabled]):checked ~ &,
.control input:checked:focus ~ &
border-color: #666
*/
// Hide default browser input
.control input:disabled ~ &
background $color--light-grey
opacity 0.6
pointer-events none
&:after
content ''
position absolute
display none // Hide check
.control input:checked ~ &
display block // Show check
// Checkbox tick
.control--checkbox &
left 5px
top 0px
width 5px
height 12px
border solid #34bb92
border-width 0 2px 2px 0
transform rotate(45deg)
// Disabled tick colour
.control--checkbox input:disabled ~ &
border-color $color--dark-grey
// Radio button inner circle
.control--radio &
left 5px
top 5px
height 6px
width 6px
border-radius 50%
background #34bb92
// Disabled circle colour
.control--radio input:disabled ~ &
background $color--dark-grey
.select
position relative
display inline-block
margin-bottom 15px
width 100%
select
display inline-block
width 100%
cursor pointer
padding 10px 15px
outline 0
border 0
border-radius 0
background $color--light-grey
color $color--dark-grey
appearance none
-webkit-appearance none
-moz-appearance none
&::-ms-expand
display none
&:hover,
&:focus
color $color--black
background $color--grey
&:disabled
opacity 0.5
pointer-events none
.select__arrow
position absolute
top 16px
right 15px
width 0
height 0
pointer-events none
border-style solid
border-width 8px 5px 0 5px
border-color $color--dark-grey transparent transparent transparent
.select select:hover ~ &
.select select:focus ~ &
border-top-color $color--black
.select select:disabled ~ &
border-top-color $color--grey
Also see: Tab Triggers