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.
body
.column
input.flat-check#checkbox1(type="checkbox")
label.flat-check-label.red-label(for="checkbox1") Red
input.flat-check#checkbox2(type="checkbox")
label.flat-check-label.orange-label(for="checkbox2") Orange
input.flat-check#checkbox3(type="checkbox")
label.flat-check-label.yellow-label(for="checkbox3") Yellow
input.flat-check#checkbox4(type="checkbox")
label.flat-check-label.green-label(for="checkbox4") Green
input.flat-check#checkbox5(type="checkbox")
label.flat-check-label.blue-label(for="checkbox5") Blue
input.flat-check#checkbox6(type="checkbox")
label.flat-check-label.purple-label(for="checkbox6") Purple
input.flat-check#checkbox7(type="checkbox")
label.flat-check-label.dark-label(for="checkbox7") Dark
.column
p Horizontal radio group.
.radio-group.radio-group--horizontal.ilc4
input.flat-radio#radio1(type="radio", name="radio-group1")
label.flat-radio-label(for="radio1") A
input.flat-radio#radio2(type="radio", name="radio-group1")
label.flat-radio-label(for="radio2") B
input.flat-radio#radio3(type="radio", name="radio-group1")
label.flat-radio-label(for="radio3") C
input.flat-radio#radio4(type="radio", name="radio-group1")
label.flat-radio-label(for="radio4") D
.column
p Vertical radio group.
.radio-group.radio-group--vertical
input.flat-radio#radio5(type="radio", name="radio-group2")
label.flat-radio-label(for="radio5") E
input.flat-radio#radio6(type="radio", name="radio-group2")
label.flat-radio-label(for="radio6") F
input.flat-radio#radio7(type="radio", name="radio-group2")
label.flat-radio-label(for="radio7") G
input.flat-radio#radio8(type="radio", name="radio-group2")
label.flat-radio-label(for="radio8") H
.column
p Checkbox group.
.checkbox-group
input.flat-check#checkbox9(type="checkbox")
label.flat-check-label.orange-label(for="checkbox9") One
input.flat-check#checkbox10(type="checkbox")
label.flat-check-label.yellow-label(for="checkbox10") Two
input.flat-check#checkbox11(type="checkbox")
label.flat-check-label.green-label(for="checkbox11") Three
input.flat-check#checkbox12(type="checkbox")
label.flat-check-label.blue-label(for="checkbox12") Four
.column
p Basic checkboxes
input.basic-check#checkbox-basic-1(type="checkbox")
label.basic-check-label(for="checkbox-basic-1") Basic
input.basic-check#checkbox-basic-2(type="checkbox")
label.basic-check-label(for="checkbox-basic-2") Checkboxes
.column
p Text input.
input(type="text")
p Disabled input.
input(type="text", disabled)
p Another text input.
input(type="text")
input.flat-slider(type="range", min="1", max="60", value="30", onchange="rangeout.value=value")
output#rangeout 30
<script src="//use.edgefonts.net/lato:n3.js"></script>
/* VARIABLES */
liteGreen = rgba(46, 204, 113,1.0)
liteBlue = rgba(52, 152, 219,1.0)
litePurple = rgba(155, 89, 182,1.0)
liteRed = rgba(231, 76, 60,1.0)
liteOrange = rgba(230, 126, 34,1.0)
liteYellow = rgba(241, 196, 15,1.0)
/* MIXINS */
flat-label(color)
background-color color
border-color color
&::after
border-color inherit
inline-children(num)
> *
width (100% / num)
/* styles */
*, *:after, *:before
box-sizing border-box
html
font-size 150%
body
margin 2rem 0
background #fafaf4;
font-family Avenir, 'lato', Lato, 'open-sans', Open Sans, sans-serif
color #333
font-weight 300
-webkit-backface-visibility hidden
div
margin 1rem 0
.column
width: 50%;
margin: 0 auto;
label
cursor pointer
.flat-check
display: none
&:checked + .flat-check-label
&:checked + .flat-check-label::after
opacity 1
.flat-check-label
display block
padding 1rem
border-radius .25em
transition .15s ease background-color
position relative
color white
opacity .6
transition .15s ease opacity
margin-bottom 1rem
text-align center
&::before
content ""
width 1rem
height 1rem
position absolute
right -2rem
border 1px solid black
background white
&::after
content: ""
width: 1rem
height: 1.5rem
position: absolute
right: -2rem
top: .5rem
border: .5rem solid
border-left: none
border-top: none
-webkit-transform: rotate(45deg)
-moz-transform: rotate(45deg)
-ms-transform: rotate(45deg)
-o-transform: rotate(45deg)
transform: rotate(45deg)
opacity: 0
transition: .15s ease opacity
// &:hover::after
// opacity: .6;
.blue-label
flat-label liteBlue
.purple-label
flat-label litePurple
.red-label
flat-label liteRed
.orange-label
flat-label liteOrange
.yellow-label
flat-label liteYellow
.green-label
flat-label liteGreen
.dark-label
flat-label rgba(52, 73, 94,1.0)
.radio-group
font-size 0
margin-bottom 2rem
& input
display none
& input:checked + label
opacity 1
cursor default
& input:checked + label::after
opacity 0
& input:checked + label::before
content ""
opacity 1
width 1rem
height 1rem
background blue
& label
font-size 1rem
display inline-block
padding 1rem
text-align center
opacity .5
position relative
transition .15s ease opacity
color white
&::after
content ""
font-size 1rem
opacity 0
width 1rem
height 1rem
border .5rem solid
border-left none
border-bottom none
position absolute
transition .15s ease opacity
&:hover::after
opacity 1
.radio-group--horizontal
& label
&:first-of-type
border-top-left-radius .25em
border-bottom-left-radius .25em
&:last-of-type
border-top-right-radius .25em
border-bottom-right-radius .25em
&::after
left 40%
bottom -1.5rem
-webkit-transform: rotate(-45deg)
-moz-transform: rotate(-45deg)
-ms-transform: rotate(-45deg)
-o-transform: rotate(-45deg)
transform: rotate(-45deg)
.radio-group--vertical
& label
display block
&:first-of-type
border-top-left-radius .25rem
border-top-right-radius .25rem
&:last-of-type
border-bottom-left-radius .25em
border-bottom-right-radius .25em
&:not(:last-of-type)
/* border-bottom 1px solid #fff */
&::after
left -2rem
top 1rem
-webkit-transform: rotate(45deg)
-moz-transform: rotate(45deg)
-ms-transform: rotate(45deg)
-o-transform: rotate(45deg)
transform: rotate(45deg)
.checkbox-group
margin 2rem 0
& label
margin-bottom 0
border-radius 0
&:first-of-type
border-top-left-radius .25rem
border-top-right-radius .25rem
&:last-of-type
border-bottom-left-radius .25em
border-bottom-right-radius .25em
&:not(:last-of-type)
/* border-bottom 1px solid #fff */
.justified
text-align justify
&:after
content ""
display inline-block
height 0
width 100%
input[name="radio-group1"] + label
flat-label liteGreen
input[name="radio-group2"] + label
flat-label liteOrange
input[type="text"]
width 100%
padding .25rem .25rem
border-radius 0
font-weight 300
transition .25s linear outline, .25s linear border
outline 8px solid transparent
border 1px solid rgba(52, 152, 219,.5)
&:hover
border-color rgba(52, 152, 219,1)
&:focus
outline 2px solid rgba(52, 152, 219,.8)
input[type="text"]:disabled
width 100%
padding .25rem .25rem
border-radius 0
font-weight 300
cursor not-allowed
background rgba(0,0,0,.01)
border 1px solid rgba(0, 0, 0,.25)
.basic-check
display: none
&:checked + .basic-check-label::after
opacity 1
.basic-check-label
padding-right 2rem
display inline-block
position relative
&::before
content ""
width .75rem
height .75rem
position absolute
bottom .25rem
right .5rem
border 1px solid #555
background white
&::after
content ""
width .75rem
height 1.25rem
position absolute
right .375rem
bottom .125rem
border .4375rem solid liteBlue
border-left none
border-top none
-webkit-transform rotate(45deg)
-moz-transform rotate(45deg)
-ms-transform rotate(45deg)
-o-transform rotate(45deg)
transform rotate(45deg)
opacity 0
transition .15s ease opacity
&:hover::after
opacity .33;
.flat-slider
margin-top 1.5rem
-webkit-appearance none
width 100%
height 1.5rem
overflow hidden
position relative
cursor pointer
&:after
position absolute
content " "
width 100%
height .5rem
right 0
top .55rem
background rgba(52, 152, 219,.35)
z-index 2
&::-webkit-slider-thumb
-webkit-appearance none
background liteBlue
width 1rem
height 1rem
// border-radius .125rem
position relative
z-index 1
outline 8px solid transparent
transition outline .3s linear
&::-webkit-slider-thumb:after
position absolute
content " "
width 100rem
height .5rem
z-index 0
right .5rem
top .25rem
background rgba(52, 152, 219,1)
&:focus
outline none
&:active
outline none
&::-webkit-slider-thumb
outline 0px solid rgba(52, 152, 219,1)
.ilc2
inline-children 2
.ilc3
inline-children 3
.ilc4
inline-children 4
.ilc5
inline-children 5
.ilc6
inline-children 6
Also see: Tab Triggers