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="background">
<div class="checkbox">
<input id="theme" type="checkbox">
<label for="theme"></label>
</div>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1000 1000" preserveAspectRatio="none"><defs><path id="a" d="M262.3 0l262.2 332.2H0z"/><linearGradient id="c" x1="52.9%" x2="52.8%" y1="67%" y2="67%"><stop offset="0%" stop-color="#EBEBEB"/><stop offset="100%" stop-color="#FFF"/></linearGradient><path id="d" d="M338.2 0l338.3 428.4H0z"/><linearGradient id="f" x1="51.3%" x2="51.5%" y1="63%" y2="63%"><stop offset="0%" stop-color="#FFF"/><stop offset="100%" stop-color="#EBEBEB"/></linearGradient><path id="g" d="M123.5.3l123.4 277.4H.1z"/><path id="i" d="M106.1.6l105.6 236.9H.5z"/><path id="k" d="M89.5.6l89 199.5H.6z"/><path id="m" d="M74.5.2l74.4 167.5H.1z"/><path id="o" d="M64 .3l63.7 143.2H.3z"/><path id="q" d="M54 .4l53.7 120.4H.3z"/><path id="s" d="M59 .2L118 133H0z"/><path id="u" d="M50.7.3l50.5 113.5H.2z"/><path id="w" d="M42.8.3l42.5 95.5H.3z"/><path id="y" d="M74.5.2l74.4 167.5H.1z"/><path id="A" d="M64 .3l63.7 143.2H.3z"/><path id="C" d="M54 .4l53.7 120.4H.3z"/><path id="E" d="M123.5.3l123.4 277.4H.1z"/><path id="G" d="M106.1.6l105.6 236.9H.5z"/><path id="I" d="M89.5.6l89 199.5H.6z"/><path id="K" d="M112 .3L223.9 252H.1z"/><path id="M" d="M96.2.5L192 215.6H.5z"/><path id="O" d="M81.2.6l80.6 181H.5z"/><path id="Q" d="M104.5.3l104.4 235.1H.1z"/><path id="S" d="M89.8.5l89.4 200.8H.4z"/><path id="U" d="M75.7.5L151 169.6H.5z"/><path id="W" d="M117 .3l116.9 263.4H.1z"/><path id="Y" d="M100.5.5l100.1 225.1H.5z"/><path id="aa" d="M84.8.6L169.1 190H.5z"/><path id="ac" d="M49.5 0s243 140 466.3 101.7c223.3-38.2 442.5-14.4 570.4-76.6 128-62.2 0 403.2 0 403.2L0 382.3 49.5 0z"/><path id="ad" d="M301 96s30.4 5.2 46 7.2c15.4 2 57 4.8 57 4.8l20 145H272l29-157z"/><linearGradient id="ae" x1="50%" x2="50%" y1="0%" y2="52.1%"><stop offset="0%" stop-color="#D95141"/><stop offset="100%" stop-color="#FACC7A"/></linearGradient></defs><g fill="none" fill-rule="evenodd"><g transform="translate(493 491.6)"><mask id="b" fill="#fff"><use xlink:href="#a"/></mask><use fill="#5E566D" xlink:href="#a"/><path fill="#41394E" d="M261.5-42.8h379.8V347H261.5z" mask="url(#b)"/><path fill="url(#c)" d="M117.7 80.5l8.1 76c1.1 10.5 9.7 15.2 19.1 10.6l31.3-15.2c9.4-4.6 24-3.5 32.6 2.6l21.2 15c8.6 6 21.8 5.2 29.5-1.9l20.7-18.9c7.7-7 20.8-7.8 29.3-1.6l33.3 24.4c8 5.8 16.4 2.8 18.8-7l31.8-130-99.9-104-175.8 150z" mask="url(#b)"/></g><g transform="translate(-18.6 396.3)"><mask id="e" fill="#fff"><use xlink:href="#d"/></mask><use fill="#4A4258" xlink:href="#d"/><path fill="#3E3749" d="M337.3-55.2H827v502.6H337.3z" mask="url(#e)"/><path fill="url(#f)" d="M151.8 103.8L189.7 216c3.3 9.9 12.3 12.2 20 5.1l47-42.8a19 19 0 0 1 26.9 1.1l20.2 22a20.3 20.3 0 0 0 27.5 2l32.5-26.6c8.1-6.6 21.5-7 30-.7l51.7 38.6c8.5 6.3 17.4 3.2 20-7l42-163.3-129-134-226.7 193.3z" mask="url(#e)"/></g><path fill="#775455" d="M12.3 622.5h42.3v181.8H12.3z"/><path fill="#634646" d="M12.4 660.7h42.2v12.4H12.4z"/><g transform="translate(-90 383.4)"><mask id="h" fill="#fff"><use xlink:href="#g"/></mask><use fill="#363E37" xlink:href="#g"/><path fill="#2C332C" d="M41.6 157.2h165.1v12.4H41.6z" mask="url(#h)"/></g><g transform="translate(-72.6 304.1)"><mask id="j" fill="#fff"><use xlink:href="#i"/></mask><use fill="#363E37" xlink:href="#i"/><path fill="#2C332C" d="M30.4 138.7h151.5v12.4H30.4z" mask="url(#j)"/></g><g transform="translate(-57.1 243.5)"><mask id="l" fill="#fff"><use xlink:href="#k"/></mask><use fill="#363E37" xlink:href="#k"/><path fill="#2C332C" d="M31 107.7h119.2v12.4H31z" mask="url(#l)"/></g><path fill="#363E37" d="M33.6 189l72.3 162.2H-38.8z"/><path fill="#523839" d="M553.7 697.8h25.5v109.8h-25.5z"/><path fill="#463031" d="M553.8 721h25.5v7.4h-25.5z"/><g transform="translate(492 553.4)"><mask id="n" fill="#fff"><use xlink:href="#m"/></mask><use fill="#384039" xlink:href="#m"/><path fill="#2B312B" d="M25.1 95h99.6v7.4H25.1z" mask="url(#n)"/></g><g transform="translate(502.5 505.5)"><mask id="p" fill="#fff"><use xlink:href="#o"/></mask><use fill="#384039" xlink:href="#o"/><path fill="#2B312B" d="M18.3 83.7h91.4v7.5H18.3z" mask="url(#p)"/></g><g transform="translate(511.8 468.9)"><mask id="r" fill="#fff"><use xlink:href="#q"/></mask><use fill="#384039" xlink:href="#q"/><path fill="#2B312B" d="M18.7 65.1h71.9v7.4H18.7z" mask="url(#r)"/></g><g fill="#384039"><path d="M566.5 436l43.7 97.9H523z"/></g><g><path fill="#523839" d="M791 681.6H811v87.1H791z"/><path fill="#463031" d="M791 700H811v5.8H791z"/><g transform="translate(742 567.1)"><mask id="t" fill="#fff"><use xlink:href="#s"/></mask><use fill="#384039" xlink:href="#s"/><path fill="#2B312B" d="M19.9 75.3h78.8v5.9H19.9z" mask="url(#t)"/></g><g transform="translate(750.3 529.1)"><mask id="v" fill="#fff"><use xlink:href="#u"/></mask><use fill="#384039" xlink:href="#u"/><path fill="#2B312B" d="M14.5 66.4h72.4v5.9H14.5z" mask="url(#v)"/></g><g transform="translate(757.7 500)"><mask id="x" fill="#fff"><use xlink:href="#w"/></mask><use fill="#384039" xlink:href="#w"/><path fill="#2B312B" d="M14.8 51.6h57v5.9h-57z" mask="url(#x)"/></g><g fill="#384039"><path d="M801 474l34.6 77.7h-69z"/></g></g><g><path fill="#523839" d="M987.7 697.8h25.5v109.8h-25.5z"/><path fill="#463031" d="M987.8 721h25.5v7.4h-25.5z"/><g transform="translate(926 553.4)"><mask id="z" fill="#fff"><use xlink:href="#y"/></mask><use fill="#384039" xlink:href="#y"/><path fill="#2B312B" d="M25.1 95h99.6v7.4H25.1z" mask="url(#z)"/></g><g transform="translate(936.5 505.5)"><mask id="B" fill="#fff"><use xlink:href="#A"/></mask><use fill="#384039" xlink:href="#A"/><path fill="#2B312B" d="M18.3 83.7h91.4v7.5H18.3z" mask="url(#B)"/></g><g transform="translate(945.8 468.9)"><mask id="D" fill="#fff"><use xlink:href="#C"/></mask><use fill="#384039" xlink:href="#C"/><path fill="#2B312B" d="M18.7 65.1h71.9v7.4H18.7z" mask="url(#D)"/></g><g fill="#384039"><path d="M1000.5 436l43.7 97.9H957z"/></g></g><path fill="#2C403D" d="M-3.5 651s243 140 466.3 101.7c223.3-38.2 442.5-14.4 570.4-76.6 128-62.2 0 403.2 0 403.2l-1086.2-46L-3.5 651z"/><path fill="#304642" d="M278.1 750s18.6 2.5 28 4.3c9.4 1.9 28.6 2.7 28.6 2.7L354 913H246l32.1-163z"/><g><path fill="#775455" d="M122.3 747.5h42.3v181.8h-42.3z"/><path fill="#634646" d="M122.4 785.7h42.2v12.4h-42.2z"/><g transform="translate(20 508.4)"><mask id="F" fill="#fff"><use xlink:href="#E"/></mask><use fill="#414B42" xlink:href="#E"/><path fill="#384038" d="M41.6 157.2h165.1v12.4H41.6z" mask="url(#F)"/></g><g transform="translate(37.4 429.1)"><mask id="H" fill="#fff"><use xlink:href="#G"/></mask><use fill="#414B42" xlink:href="#G"/><path fill="#384038" d="M30.4 138.7h151.5v12.4H30.4z" mask="url(#H)"/></g><g transform="translate(52.9 368.5)"><mask id="J" fill="#fff"><use xlink:href="#I"/></mask><use fill="#414B42" xlink:href="#I"/><path fill="#384038" d="M31 107.7h119.2v12.4H31z" mask="url(#J)"/></g><g fill="#414B42"><path d="M143.6 314l72.3 162.2H71.2z"/></g></g><g><path fill="#775455" d="M438.8 815.4h38.4v165h-38.4z"/><path fill="#634646" d="M438.8 850.1h38.3v11.2h-38.3z"/><g transform="translate(346 598.4)"><mask id="L" fill="#fff"><use xlink:href="#K"/></mask><use fill="#414B42" xlink:href="#K"/><path fill="#384038" d="M37.7 142.7h149.7V154H37.7z" mask="url(#L)"/></g><g transform="translate(361.8 526.5)"><mask id="N" fill="#fff"><use xlink:href="#M"/></mask><use fill="#414B42" xlink:href="#M"/><path fill="#384038" d="M27.6 125.9H165v11.2H27.6z" mask="url(#N)"/></g><g transform="translate(375.8 471.4)"><mask id="P" fill="#fff"><use xlink:href="#O"/></mask><use fill="#414B42" xlink:href="#O"/><path fill="#384038" d="M28.1 97.8h108.1V109H28.1z" mask="url(#P)"/></g><g fill="#414B42"><path d="M458 422l65.7 147.2H392.5z"/></g></g><g><path fill="#775455" d="M877.6 801.4h35.8v154.1h-35.8z"/><path fill="#634646" d="M877.6 833.8h35.7v10.5h-35.7z"/><g transform="translate(791 598.8)"><mask id="R" fill="#fff"><use xlink:href="#Q"/></mask><use fill="#414B42" xlink:href="#Q"/><path fill="#384038" d="M35.2 133.3h139.7v10.5H35.2z" mask="url(#R)"/></g><g transform="translate(805.7 531.6)"><mask id="T" fill="#fff"><use xlink:href="#S"/></mask><use fill="#414B42" xlink:href="#S"/><path fill="#384038" d="M25.7 117.5h128.2V128H25.7z" mask="url(#T)"/></g><g transform="translate(818.8 480.2)"><mask id="V" fill="#fff"><use xlink:href="#U"/></mask><use fill="#414B42" xlink:href="#U"/><path fill="#384038" d="M26.3 91.3h100.8v10.5H26.3z" mask="url(#V)"/></g><g fill="#414B42"><path d="M895.6 434l61.2 137.5H834.4z"/></g></g><g><path fill="#775455" d="M656 773.7h40v172.7h-40z"/><path fill="#634646" d="M656 810h40V822h-40z"/><g transform="translate(559 546.6)"><mask id="X" fill="#fff"><use xlink:href="#W"/></mask><use fill="#455146" xlink:href="#W"/><path fill="#384038" d="M39.4 149.3h156.4v11.8H39.4z" mask="url(#X)"/></g><g transform="translate(575.5 471.4)"><mask id="Z" fill="#fff"><use xlink:href="#Y"/></mask><use fill="#455146" xlink:href="#Y"/><path fill="#384038" d="M28.8 131.7h143.5v11.8H28.8z" mask="url(#Z)"/></g><g transform="translate(590.1 413.7)"><mask id="ab" fill="#fff"><use xlink:href="#aa"/></mask><use fill="#455146" xlink:href="#aa"/><path fill="#384038" d="M29.4 102.3h112.9v11.8H29.4z" mask="url(#ab)"/></g><g fill="#455146"><path d="M676 362l68.5 154h-137z"/></g></g><g transform="translate(-70 788)"><use fill="#324643" xlink:href="#ac"/><use fill="#374E4B" xlink:href="#ad"/></g><path fill="url(#ae)" d="M0 0h1000v1000H0z" opacity=".4" style="mix-blend-mode:color"/></g></svg>
</div>
html {
background: #1b1b1b;
}
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
.checkbox {
position: absolute;
top: 30px;
right: 13px;
z-index: 100000;
}
.checkbox span {
transition: transform 300ms ease-in-out 200ms,
opacity 300ms ease-in-out 200ms;
}
.checkbox input {
display: block;
-webkit-appearance: none;
width: 70px;
border-bottom: 0;
}
.checkbox label {
background: rgba(255, 255, 255, 0.6);
position: absolute;
top: 0;
bottom: 0;
margin: auto;
width: 100%;
height: 30px;
content: "";
border-radius: 10px;
}
.checkbox label:hover span {
transform: translate3d(0, 0, 0);
opacity: 1;
}
.checkbox label:after {
position: absolute;
top: 0;
bottom: 0;
left: 5px;
margin: auto;
width: 20px;
height: 20px;
border-radius: 6px;
background: white;
content: "";
transition: left 350ms linear, background 350ms ease-in-out;
}
.checkbox input:checked + label:after {
left: calc(100% - 25px);
background: #1b1b1b;
}
.background {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
width: 500px;
height: 500px;
background-image: linear-gradient(-180deg, #D95141 0%, #FACC7A 52%);
overflow: hidden;
border-radius: 10px;
}
.background::after {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
content: "";
background: #27214c;
opacity: 0;
transition: opacity 1500ms ease-in-out;
}
.background::before {
position: absolute;
top: 100px;
left: 0;
right: 0;
margin: auto;
width: 440px;
height: 440px;
background: linear-gradient(-180deg, rgba(225, 225, 225, 0.4), transparent);
content: "";
z-index: 1000;
border-radius: 100%;
transform: translate3d(0, 0, 0);
opacity: 1;
transition: transform 3500ms ease-in-out, opacity 3500ms ease-in-out;
}
.dark .background::after {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
content: "";
opacity: 1;
}
.dark .background::before {
transform: translate3d(0, 60px, 0);
opacity: 0;
}
.background svg {
position: relative;
z-index: 10000;
}
const themeValue = JSON.parse(localStorage.getItem('darkTheme'))
const theme = document.getElementById('theme')
const html = document.documentElement
themeValue ? html.classList.add('dark') : html.classList.remove('dark')
theme.addEventListener('click', function () {
localStorage.setItem('darkTheme', theme.checked)
theme.checked ? html.classList.add('dark') : html.classList.remove('dark')
})
theme.checked = themeValue
Also see: Tab Triggers