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.
<script src="http://variancecharts.com/cdn/variance-noncommercial-standalone-f47ffcf.min.js" charset="UTF-8"></script>
<link id="global-temp-annual" rel="variance-data" href="//variancecharts.com/data/global_temp_annual_mean.csv">
<link id="global-temp-fiveyear" rel="variance-data" href="//variancecharts.com/data/global_temp_fiveyear_mean.csv">
<link id="global-temp-monthly" rel="variance-data" href="//variancecharts.com/data/global_temp_monthly_recordings.csv">
<div id="global_temp">
<chart class="global-temp" data="#global-temp-annual" map-xy="year annual_mean" scale-x-linear="1878 2020" scale-y-linear="-0.8 1.0"><guide-x ticks="1880 1900 1920 1940 1960 1980 2000 2010"></guide-x><guide-y class="right" ticks="-0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8"><span class="label"> {{value}} °C</span>
</guide-y><points class="monthly" data="#global-temp-monthly" map-xy="year jan"></points><points class="monthly" data="#global-temp-monthly" map-xy="year feb"></points><points class="monthly" data="#global-temp-monthly" map-xy="year mar"></points><points class="monthly" data="#global-temp-monthly" map-xy="year apr"></points><points class="monthly" data="#global-temp-monthly" map-xy="year may"></points><points class="monthly" data="#global-temp-monthly" map-xy="year jun"></points><points class="monthly" data="#global-temp-monthly" map-xy="year jul"></points><points class="monthly" data="#global-temp-monthly" map-xy="year aug"></points><points class="monthly" data="#global-temp-monthly" map-xy="year sep"></points><points class="monthly" data="#global-temp-monthly" map-xy="year oct"></points><points class="monthly" data="#global-temp-monthly" map-xy="year nov"></points><points class="monthly" data="#global-temp-monthly" map-xy="year dec"></points><line class="annual-mean"></line><line class="five-year-mean" data="#global-temp-fiveyear" map-xy="year five_year_mean"></line><repeat class="annual-means"><point class="annual-mean"></point></repeat><div class="title">
<h4>Global Surface Temperature</h4>
<p>Change in global surface temperature relative to 1951-1980 average temperatures.</p>
</div>
</chart><div class="legend-wrapper">
<div class="legend">
<ul>
<li class="monthly">
<span class="icon"></span>
<span class="description">Monthly Mean</span>
</li>
<li class="annual">
<span class="icon"></span>
<span class="description">Annual Mean</span>
</li>
<li class="fiveyear">
<span class="icon"></span>
<span class="description">Five Year Mean</span>
</li>
</ul>
</div>
<div class="source">
<p>Source: NASA’s Goddard Institute for Space Studies (GISS)</p>
</div>
</div>
</div>
#global_temp {
padding: 40px;
font-family: "Helvetica", "Arial", "sans-serif";
}
#global_temp .global-temp {
width: 100%;
height: 400px;
max-width: 1100px;
}
#global_temp .global-temp guide-x, #global_temp .global-temp guide-y {
color: #b1b1aa;
}
#global_temp .global-temp guide-y {
width: 100%;
right: 0;
border: none;
overflow: visible;
font-size: 14px;
}
#global_temp .global-temp guide-y .tick {
width: 100%;
border-bottom: 1px dotted #dddddd;
}
#global_temp .global-temp guide-y .tick .label {
right: 6px;
left: auto;
width: auto;
background-color: #f8f8f2;
padding: 0 4px;
}
#global_temp .global-temp guide-x {
border-top: 1px solid #dddddd;
overflow: visible;
font-size: 16px;
}
#global_temp .global-temp guide-x .tick {
border-left: 1px solid #dddddd;
}
#global_temp .global-temp point {
background-color: #585a8b;
width: 5px;
height: 5px;
border-radius: 50%;
margin-left: -2.5px;
margin-bottom: -2.5px;
}
#global_temp .global-temp point:last-child {
color: red;
}
#global_temp .global-temp repeat.annual-means {
-moz-animation-name: intro;
-webkit-animation-name: intro;
animation-name: intro;
-moz-animation-duration: 2s;
-webkit-animation-duration: 2s;
animation-duration: 2s;
-moz-animation-timing-function: ease-in;
-webkit-animation-timing-function: ease-in;
animation-timing-function: ease-in;
-moz-animation-fill-mode: forwards;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
-moz-animation-delay: 2s;
-webkit-animation-delay: 2s;
animation-delay: 2s;
opacity: 0;
-moz-transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;
}
#global_temp .global-temp repeat.annual-means datum:last-child point {
background-color: #585a8b;
width: 6px;
height: 6px;
border-radius: 50%;
margin-left: -3px;
margin-bottom: -3px;
}
#global_temp .global-temp repeat.northern point {
background-color: #dddddd;
width: 5px;
height: 5px;
border-radius: 50%;
margin-left: -2.5px;
margin-bottom: -2.5px;
}
#global_temp .global-temp line.northern svg path {
stroke: #dddddd;
}
#global_temp .global-temp line.annual-mean svg path {
stroke: #585a8b;
stroke-width: 1px;
stroke-dasharray: 2800px;
stroke-dashoffset: 2800px;
-moz-animation-name: drawstroke;
-webkit-animation-name: drawstroke;
animation-name: drawstroke;
-moz-animation-duration: 4s;
-webkit-animation-duration: 4s;
animation-duration: 4s;
-moz-animation-timing-function: ease-in-out;
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
-moz-animation-fill-mode: forwards;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
-moz-animation-delay: 2s;
-webkit-animation-delay: 2s;
animation-delay: 2s;
-moz-transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
#global_temp .global-temp line.five-year-mean svg path {
stroke: #f64b49;
stroke-width: 2px;
stroke-dasharray: 1400px;
stroke-dashoffset: 1400px;
-moz-animation-name: drawstroke;
-webkit-animation-name: drawstroke;
animation-name: drawstroke;
-moz-animation-duration: 4s;
-webkit-animation-duration: 4s;
animation-duration: 4s;
-moz-animation-timing-function: ease-in-out;
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
-moz-animation-fill-mode: forwards;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
-moz-animation-delay: 2s;
-webkit-animation-delay: 2s;
animation-delay: 2s;
-moz-transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
#global_temp .global-temp point.monthly {
background-color: rgba(0, 0, 0, 0.08);
width: 6px;
height: 6px;
border-radius: 50%;
margin-left: -3px;
margin-bottom: -3px;
}
#global_temp .global-temp .five-year-mean point {
background-color: red;
width: 4px;
height: 4px;
border-radius: 50%;
margin-left: -2px;
margin-bottom: -2px;
}
#global_temp .title {
width: 320px;
padding: 0 8px;
position: absolute;
left: 20px;
top: 60px;
}
#global_temp .title h4 {
margin: 0 0 2px 0;
padding: 0;
background: #f8f8f2;
color: #4b4b4b;
}
#global_temp .title p {
margin: 0;
padding: 0;
background: #f8f8f2;
display: inline;
color: #8d8d87;
line-height: 1.2;
font-size: 15px;
}
#global_temp .legend-wrapper {
margin-top: 60px;
display: -webkit-flex;
display: flex;
-webkit-justify-content: space-between;
justify-content: space-between;
max-width: 1100px;
margin-left: auto;
margin-right: auto;
}
#global_temp .legend {
-webkit-flex: 1;
flex: 1;
}
#global_temp .legend ul {
list-style: none;
margin: 0;
padding: 0;
display: -webkit-flex;
display: flex;
}
#global_temp .legend li {
color: #b1b1aa;
font-size: 14px;
margin-right: 18px;
}
#global_temp .legend li.monthly, #global_temp .legend li.annual, #global_temp .legend li.fiveyear {
display: -webkit-flex;
display: flex;
-webkit-align-items: center;
align-items: center;
}
#global_temp .legend li.monthly .description, #global_temp .legend li.annual .description, #global_temp .legend li.fiveyear .description {
margin-left: 6px;
}
#global_temp .legend li.monthly .icon {
width: 6px;
height: 6px;
border-radius: 50%;
background-color: rgba(0, 0, 0, 0.2);
display: inline-block;
}
#global_temp .legend li.annual .icon {
width: 14px;
height: 1px;
background-color: #585a8b;
position: relative;
}
#global_temp .legend li.annual .icon:after {
content: "";
width: 6px;
height: 6px;
background-color: #585a8b;
border-radius: 50%;
display: block;
position: absolute;
left: 4px;
top: -3px;
}
#global_temp .legend li.fiveyear .icon {
width: 14px;
height: 2px;
background-color: #f64b49;
}
#global_temp .source {
-webkit-flex: 1;
flex: 1;
text-align: right;
}
#global_temp .source p {
color: #b1b1aa;
margin: 0;
padding: 0;
font-size: 14px;
}
/* Keyframe animations */
@-moz-keyframes intro {
0% {
opacity: 1;
}
100% {
opacity: 1;
}
}
@-webkit-keyframes intro {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes intro {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@-moz-keyframes drawstroke {
100% {
stroke-dashoffset: 0px;
}
}
@-webkit-keyframes drawstroke {
100% {
stroke-dashoffset: 0px;
}
}
@keyframes drawstroke {
100% {
stroke-dashoffset: 0px;
}
}
body {
background-color: #f8f8f2;
}
Also see: Tab Triggers