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>
<ul>
<li><input type="radio" name="tab" id="home"><label for="home">
<svg viewBox="0 0 211 212"><path d="M211 205l0 -112c0,-5 -1,-9 -5,-12l-88 -77c-6,-5 -15,-5 -21,0l-91 78c-4,3 -6,7 -6,12l0 111c0,4 3,7 8,7l56 0c5,0 8,-3 8,-7l0 -56c0,-15 12,-26 26,-26l15 0c15,0 26,11 26,26l0 56c0,4 4,7 8,7l57 0c4,0 7,-3 7,-7z"/></svg>
Home
</label></li>
<li><input type="radio" name="tab" id="likes"><label for="likes">
<svg viewBox="0 0 90 90"><path d="M45,23.9L45,23.9c0,0,18.1-22.3,37.3-5.4c11.3,9.9,9.7,25.4-2,37.1L45,89.7L9.7,55.6C-2,43.9-3.6,28.4,7.7,18.5 C26.9,1.6,45,23.9,45,23.9L45,23.9z"/></svg>
Likes
</label></li>
<li><input type="radio" name="tab" id="chats"><label for="chats">
<svg viewBox="0 0 100 100"><path d="M92.77,0H7.23A7,7,0,0,0,0,6.72V68.83a7,7,0,0,0,7.23,6.72H40.5L73,100V75.55H92.77A7,7,0,0,0,100,68.83V6.72A7,7,0,0,0,92.77,0Z"/></svg>
Chats
</label></li>
<li><input type="radio" name="tab" id="settings"><label for="settings">
<svg viewBox="0 0 270 270"><path class="fil0" d="M166 39c5,2 10,4 15,6l24 -18c5,-3 11,-2 14,1l22 22c4,4 4,10 1,14l-17 25c2,5 4,10 6,15l30 5c5,0 9,5 9,10l0 31c0,5 -4,10 -9,11l-30 5c-2,5 -4,10 -6,15l18 24c3,5 2,11 -1,14l-22 22c-4,4 -10,4 -14,1l-25 -17c-5,2 -10,4 -15,6l-5 30c-1,5 -6,9 -11,9l-31 0c-5,0 -10,-4 -10,-9l-5 -30c-5,-2 -10,-4 -15,-6l-25 17c-4,3 -10,3 -14,-1l-22 -22c-3,-3 -4,-9 -1,-13l18 -25c-3,-5 -5,-10 -6,-15l-30 -5c-5,-1 -9,-6 -9,-11l0 -31c0,-5 4,-10 9,-10l30 -5c1,-6 3,-10 6,-15l-18 -25c-3,-4 -2,-10 2,-14l22 -22c3,-3 9,-4 13,-1l25 18c5,-2 10,-4 15,-6l5 -30c0,-5 5,-9 10,-9l31 0c5,0 10,4 11,9l5 30zm-31 39c-31,0 -57,26 -57,57 0,31 26,57 57,57 31,0 57,-26 57,-57 0,-31 -26,-57 -57,-57z"/></svg>
Settings
</label></li>
</ul>
</nav>
*, *::before, *::after {
box-sizing: border-box;
}
body {
background: rgb(230 229 230);
}
nav {
position: absolute;
inset: 0;
margin: auto;
height: 6rem;
width: 24rem;
background: #fff;
font-family: sans-serif;
font-weight: 600;
border-radius: 2rem;
padding: 0 1rem;
box-shadow:
0 -1.1px 2.2px rgba(0, 0, 0, 0.02),
0 -2.7px 5.3px rgba(0, 0, 0, 0.028),
0 -5px 10px rgba(0, 0, 0, 0.035),
0 -8.9px 17.9px rgba(0, 0, 0, 0.042),
0 -16.7px 33.4px rgba(0, 0, 0, 0.05),
0 -40px 80px rgba(0, 0, 0, 0.07);
ul {
display: flex;
justify-content: space-between;
height: 100%;
align-items: center;
}
li {
display: contents;
&:nth-of-type(1) {
--clr-accent-h: 133deg;
--clr-accent-s: 54%;
--clr-accent-l: 53%;
}
&:nth-of-type(2) {
--clr-accent-h: 349deg;
--clr-accent-s: 100%;
--clr-accent-l: 83%;
}
&:nth-of-type(3) {
--clr-accent-h: 220deg;
--clr-accent-s: 83%;
--clr-accent-l: 69%;
}
&:nth-of-type(4) {
--clr-accent-h: 252deg;
--clr-accent-s: 52%;
--clr-accent-l: 52%;
}
}
label {
position: relative;
font-size: 0;
line-height: 1rem;
border-radius: 100vmax;
padding: 1rem 1rem;
padding-inline-start: 2rem;
width: 3rem;
transition:
padding-inline-start .3s .25s linear,
width .3s .25s linear,
color .3s linear,
font-size 0s .3s linear,
background .3s linear;
color: transparent;
text-align: center;
cursor: pointer;
border: solid 2px transparent;
svg {
position: absolute;
width: 1.2rem;
height: 1.2rem;
inset-inline-start: .9rem;
inset-block: 0;
margin: auto;
fill: hsl(300deg,2%,80%);
transition: fill .2s linear;
}
&::before {
content: "";
position: fixed;
inset: 0;
background: HSLA(var(--clr-accent-h), var(--clr-accent-s), var(--clr-accent-l));
z-index: -1;
opacity: 0;
transition: opacity .3s .45s linear;
pointer-events: none;
}
}
input {
position: absolute;
width: 0;
height: 0;
}
input:checked + label {
background: HSLA(var(--clr-accent-h), var(--clr-accent-s), var(--clr-accent-l), .25);
font-size: 1rem;
width: 8rem;
color: HSLA(var(--clr-accent-h), var(--clr-accent-s), var(--clr-accent-l));
padding-inline-start: 3rem;
transition:
padding-inline-start .3s .25s linear,
width .3s .25s linear,
color .3s .5s linear,
font-size 0s linear,
background .3s linear;
svg {
fill: HSLA(var(--clr-accent-h), var(--clr-accent-s), var(--clr-accent-l));
}
&::before {
opacity: 1;
transition: opacity .3s .15s linear;
}
}
label:hover svg {
fill: HSLA(var(--clr-accent-h), var(--clr-accent-s), var(--clr-accent-l));
}
input:focus + label {
outline: none;
border: solid 2px HSLA(var(--clr-accent-h), var(--clr-accent-s), var(--clr-accent-l));
}
}
Also see: Tab Triggers