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.
#nav-bar
input#nav-toggle(type='checkbox')
#nav-header
a#nav-title(href='https://codepen.io' target='_blank').
C#[i.fab.fa-codepen]DEPEN
label(for='nav-toggle')
span#nav-toggle-burger
hr
#nav-content
.nav-button #[i.fas.fa-palette]#[span Your Work]
.nav-button #[i.fas.fa-images]#[span Assets]
.nav-button #[i.fas.fa-thumbtack]#[span Pinned Items]
hr
.nav-button #[i.fas.fa-heart]#[span Following]
.nav-button #[i.fas.fa-chart-line]#[span Trending]
.nav-button #[i.fas.fa-fire]#[span Challenges]
.nav-button #[i.fas.fa-magic]#[span Spark]
hr
.nav-button #[i.fas.fa-gem]#[span Codepen Pro]
#nav-content-highlight
input#nav-footer-toggle(type='checkbox')
#nav-footer
#nav-footer-heading
#nav-footer-avatar
img(src='https://gravatar.com/avatar/4474ca42d303761c2901fa819c4f2547')
#nav-footer-titlebox
a#nav-footer-title(href='https://codepen.io/uahnbu/pens/public' target='_blank') uahnbu
span#nav-footer-subtitle Admin
label(for='nav-footer-toggle')
i.fas.fa-caret-up
#nav-footer-content
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
:root
--background: #9c88ff
--navbar-width: 256px
--navbar-width-min: 80px
--navbar-dark-primary: #18283b
--navbar-dark-secondary: #2c3e50
--navbar-light-primary: #f5f6fa
--navbar-light-secondary: #8392a5
html, body
margin: 0
background: var(--background)
#nav-toggle:checked
& ~ #nav-header
width: calc(var(--navbar-width-min) - 16px)
& ~#nav-content, & ~ #nav-footer
width: var(--navbar-width-min)
& ~ #nav-header
#nav-title
opacity: 0
pointer-events: none
transition: opacity .1s
label[for="nav-toggle"]
left: calc(50% - 8px)
transform: translate(-50%)
#nav-toggle-burger
background: var(--navbar-light-primary)
&:before, &::after
width: 16px
background: var(--navbar-light-secondary)
transform: translate(0, 0) rotate(0deg)
& ~ #nav-content
.nav-button
span
opacity: 0
transition: opacity .1s
.fas
min-width: calc(100% - 16px)
& ~ #nav-footer
#nav-footer-avatar
margin-left: 0
left: 50%
transform: translate(-50%)
#nav-footer-titlebox, label[for="nav-footer-toggle"]
opacity: 0
transition: opacity .1s
pointer-events: none
#nav-bar
position: absolute
left: 1vw
top: 1vw
height: calc(100% - 2vw)
background: var(--navbar-dark-primary)
border-radius: 16px
display: flex
flex-direction: column
color: var(--navbar-light-primary)
font-family: Verdana, Geneva, Tahoma, sans-serif
overflow: hidden
user-select: none
hr
margin: 0
position: relative
left: 16px
width: calc(100% - 32px)
border: none
border-top: solid 1px var(--navbar-dark-secondary)
a
color: inherit
text-decoration: inherit
input[type="checkbox"]
display: none
#nav-header
position: relative
width: var(--navbar-width)
left: 16px
width: calc(var(--navbar-width) - 16px)
min-height: 80px
background: var(--navbar-dark-primary)
border-radius: 16px
z-index: 2
display: flex
align-items: center
transition: width .2s
hr
position: absolute
bottom: 0
#nav-title
font-size: 1.5rem
transition: opacity 1s
label[for="nav-toggle"]
position: absolute
right: 0
width: 3rem
height: 100%
display: flex
align-items: center
justify-content: center
cursor: pointer
#nav-toggle-burger
position: relative
width: 16px
height: 2px
background: var(--navbar-dark-primary)
border-radius: 99px
transition: background .2s
&:before, &:after
content: ''
position: absolute
top: -6px
width: 10px
height: 2px
background: var(--navbar-light-primary)
border-radius: 99px
transform: translate(2px, 8px) rotate(30deg)
transition: .2s
&:after
top: 6px
transform: translate(2px, -8px) rotate(-30deg)
#nav-content
margin: -16px 0
padding: 16px 0
position: relative
flex: 1
width: var(--navbar-width)
background: var(--navbar-dark-primary)
box-shadow: 0 0 0 16px var(--navbar-dark-primary)
direction: rtl
overflow-x: hidden
transition: width .2s
&::-webkit-scrollbar
width: 8px
height: 8px
&::-webkit-scrollbar-thumb
border-radius: 99px
background-color: #D62929
&::-webkit-scrollbar-button
height: 16px
#nav-content-highlight
position: absolute
left: 16px
top: -54 - 16px
width: calc(100% - 16px)
height: 54px
background: var(--background)
background-attachment: fixed
border-radius: 16px 0 0 16px
transition: top .2s
&:before, &:after
content: ''
position: absolute
right: 0
bottom: 100%
width: 32px
height: 32px
border-radius: 50%
box-shadow: 16px 16px var(--background)
&:after
top: 100%
box-shadow: 16px -16px var(--background)
.nav-button
position: relative
margin-left: 16px
height: 54px
display: flex
align-items: center
color: var(--navbar-light-secondary)
direction: ltr
cursor: pointer
z-index: 1
transition: color .2s
span
transition: opacity 1s
.fas
transition: min-width .2s
@for $i from 1 through 8
&:nth-of-type(#{$i}):hover
color: var(--navbar-dark-primary)
& ~ #nav-content-highlight
top: ($i - 1) * 54 + 16px
#nav-bar .fas
min-width: 3rem
text-align: center
#nav-footer
position: relative
width: var(--navbar-width)
height: 54px
background: var(--navbar-dark-secondary)
border-radius: 16px
display: flex
flex-direction: column
z-index: 2
transition: width .2s, height .2s
#nav-footer-heading
position: relative
width: 100%
height: 54px
display: flex
align-items: center
#nav-footer-avatar
position: relative
margin: 11px 0 11px 16px
left: 0
width: 32px
height: 32px
border-radius: 50%
overflow: hidden
transform: translate(0)
transition: .2s
img
height: 100%
#nav-footer-titlebox
position: relative
margin-left: 16px
width: 10px
display: flex
flex-direction: column
transition: opacity 1s
#nav-footer-subtitle
color: var(--navbar-light-secondary)
font-size: .6rem
#nav-toggle:not(:checked) ~ #nav-footer-toggle:checked + #nav-footer
height: 30%
min-height: 54px
label[for="nav-footer-toggle"]
transform: rotate(180deg)
label[for="nav-footer-toggle"]
position: absolute
right: 0
width: 3rem
height: 100%
display: flex
align-items: center
cursor: pointer
transition: transform .2s, opacity .2s
#nav-footer-content
margin: 0 16px 16px 16px
border-top: solid 1px var(--navbar-light-secondary)
padding: 16px 0
color: var(--navbar-light-secondary)
font-size: .8rem
overflow: auto
&::-webkit-scrollbar
width: 8px
height: 8px
&::-webkit-scrollbar-thumb
border-radius: 99px
background-color: #D62929
Also see: Tab Triggers