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>
<article>
<h1>List of Current NBA Teams</h1>
<p>
There are 30 teams in the NBA and they are divided equally with 15 teams into different conferences. Each conference is made up of three divisions with five teams in each group. Check out the list below to locate your favorite NBA team to bet on when basketball season is underway.
</p>
<p>
Each NBA team has fifteen players. Twelve players are considered part of the active roster and can dress out to play in a game. The other three are inactive or in reserve. Five players play per team at a time. There aren't any special positions by rule in the NBA. Positions are more through different roles played on the court as set up by the coach.
</p>
<strong class="label"><span>⇣</span>Scroll Down to See the List<span>⇣</span></strong>
</article>
<section>
<h2 class="first">
<span class="title">
<span>
Eastern Conference
</span>
</span>
</h2>
<section>
<h3>
<span class="title">
<span>
Atlantic Division
</span>
</span>
</h3>
<ul>
<li>Boston Celtics</li>
<li>Brooklyn Nets</li>
<li>New York Knicks</li>
<li>Philadelphia 76ers</li>
<li>Toronto Raptors</li>
</ul>
</section>
<section>
<h3>
<span class="title">
<span>
Central Division
</span>
</span>
</h3>
<ul>
<li>Chicago Bulls</li>
<li>Cleveland Cavaliers</li>
<li>Detroit Pistons</li>
<li>Indiana Pacers</li>
<li>Milwaukee Bucks</li>
</ul>
</section>
<section>
<h3>
<span class="title">
<span>
Southeast Division
</span>
</span>
</h3>
<ul>
<li>Atlanta Hawks</li>
<li>Charlotte Hornets</li>
<li>Miami Heat</li>
<li>Orlando Magic</li>
<li>Washington Wizards</li>
</ul>
</section>
</section>
<section>
<h2>
<span class="title">
<span>
Western Conference
</span>
</span>
</h2>
<section>
<h3>
<span class="title">
<span>
Northwest Division
</span>
</span>
</h3>
<ul>
<li>Denver Nuggets</li>
<li>Minnesota Timberwolves</li>
<li>Oklahoma City Thunder</li>
<li>Portland Trail Blazers</li>
<li>Portland Trail Blazers</li>
</ul>
</section>
<section>
<h3>
<span class="title">
<span>
Pacific Division
</span>
</span>
</h3>
<ul>
<li>Golden State Warriors</li>
<li>Los Angeles Clippers</li>
<li>Los Angeles Lakers</li>
<li>Phoenix Suns</li>
<li>Sacramento Kings</li>
</ul>
</section>
<section>
<h3>
<span class="title">
<span>
Southwest Division
</span>
</span>
</h3>
<ul>
<li>Dallas Mavericks</li>
<li>Houston Rockets</li>
<li>Memphis Grizzlies</li>
<li>New Orleans Pelicans</li>
<li>San Antonio Spurs</li>
</ul>
</section>
</section>
</div>
.title {
animation-timeline: view(block);
animation-name: shrink;
animation-range: entry -10% contain 40%;
}
@keyframes shrink {
from {
width: 100%;
scale: 0.8;
opacity: 0;
}
to {
width: calc(50% - 2px);
scale: 1;
opacity: 1;
}
}
li {
animation-timeline: view(block);
animation-name: grow;
animation-range: entry -10% contain 40%;
}
@keyframes grow {
from {
scale: 0.8;
opacity: 0;
}
to {
scale: 1;
opacity: 1;
}
}
.label {
animation-timeline: view(block);
animation-name: fadeout;
animation-range: contain 0% contain 100%;
}
@keyframes fadeout {
from {
scale: 1;
opacity: 1;
}
to {
translate: 0 -250%;
scale: 0.8;
opacity: 0;
}
}
/* Base Styles */
* {
box-sizing: border-box;
}
html {
font-family: Arial, Helvetica, sans-serif;
color: #777;
height: 100%;
}
body {
display: grid;
place-items: center;
margin: 0;
height: 100%;
}
div {
border: solid 1px #ccc;
height: var(--height);
width: 90vw;
overflow-y: auto;
overflow-x: hidden;
--height: 500px;
}
article {
padding: 1.25em;
position: relative;
min-height: var(--height);
}
.label {
align-items: center;
bottom: 1em;
color: #ff495d;
display: flex;
gap: 0.25em;
justify-content: center;
position: absolute;
left: 0;
right: 0;
}
.label span {
font-size: 125%;
}
section {
position: relative;
}
section:last-of-type section:last-of-type {
min-height: var(--height);
}
h1 {
color: #333;
}
p {
font-size: 18px;
line-height: 1.5;
}
h2, h3 {
color: white;
display: flex;
font-size: 1.5em;
margin: 0;
position: sticky;
top: 0;
}
h2::before, h3::before {
background: #ccc;
content: '';
height: 1px;
position: absolute;
width: 100%;
}
h2 {
justify-content: flex-end;
margin-bottom: 0.25rem;
z-index: 2;
}
h2::before {
right: 0;
top: 0;
}
h3 {
z-index: 1;
}
h3::before {
left: 0;
bottom: 0;
}
.title {
align-items: center;
display: flex;
font-size: 85%;
height: 50px;
padding-inline: 0.5em;
min-width: calc(50% - 2px);
}
h2 .title {
background-color: #6244b0;
transform-origin: right;
}
h3 .title {
background-color: #3dc0d1;
transform-origin: left;
}
ul {
list-style: none;
margin: 0;
font-size: 18px;
padding: 0 0.25rem;
}
li {
background-color: rgba(0, 0, 0, 0.05);
line-height: 1.5;
margin-block: 0.25rem;
padding: 0.75em 1em;
transform-origin: left;
}
Also see: Tab Triggers