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.
<h1>Table template</h1>
<table>
<caption>Data about the planets of our solar system (Planetary facts taken from <a href="http://nssdc.gsfc.nasa.gov/planetary/factsheet/">Nasa's Planetary Fact Sheet - Metric</a>).</caption>
<colgroup><col span="2"><col style="border:2px solid black"><col span="9"></colgroup>
<thead>
<tr>
<td colspan="2"> </td>
<th id="name">Name</th>
<th id="mass">Mass (10<sup>24</sup>kg)</th>
<th id="diam">Diameter (km)</th>
<th id="dens">Density (kg/m<sup>3</sup>)</th>
<th id="grav">Gravity (m/s<sup>2</sup>)</th>
<th id="lday">Length of day (hours)</th>
<th id="dist">Distance from Sun (10<sup>6</sup>km)</th>
<th id="temp">Mean temperature (В°C)</th>
<th id="moons">Number of moons</th>
<th id="note">Notes</th>
</tr>
</thead>
<tbody>
<tr>
<th id="terr" colspan="2" rowspan="4">Terrestrial planets</th>
<th id="merc">Mercury</th>
<td headers="terr merc mass">0.330</td>
<td headers="terr merc diam">4,879</td>
<td headers="terr merc dens">5427</td>
<td headers="terr merc grav">3.7</td>
<td headers="terr merc lday">4222.6</td>
<td headers="terr merc dist">57.9</td>
<td headers="terr merc temp">167</td>
<td headers="terr merc moons">0</td>
<td headers="terr merc note">Closest to the Sun</td>
</tr>
<tr>
<th id="venus">Venus</th>
<td headers="terr venus mass">4.87</td>
<td headers="terr venus diam">12,104</td>
<td headers="terr venus dens">5243</td>
<td headers="terr venus grav">8.9</td>
<td headers="terr venus lday">2802.0</td>
<td headers="terr venus dist">108.2</td>
<td headers="terr venus temp">464</td>
<td headers="terr venus moons">0</td>
<td headers="terr venus note"> </td>
</tr>
<tr>
<th id="earth">Earth</th>
<td headers="terr earth mass">5.97</td>
<td headers="terr earth diam">12,756</td>
<td headers="terr earth dens">5514</td>
<td headers="terr earth grav">9.8</td>
<td headers="terr earth lday">24.0</td>
<td headers="terr earth dist">149.6</td>
<td headers="terr earth temp">15</td>
<td headers="terr earth moons">1</td>
<td headers="terr earth note">Our world</td>
</tr>
<tr>
<th id="mars">Mars</th>
<td headers="terr mars mass">0.642</td>
<td headers="terr mars diam">6,792</td>
<td headers="terr mars dens">3933</td>
<td headers="terr mars grav">3.7</td>
<td headers="terr mars lday">24.7</td>
<td headers="terr mars dist">227.9</td>
<td headers="terr mars temp">-65</td>
<td headers="terr mars moons">2</td>
<td headers="terr mars note">The red planet</td>
</tr>
<tr>
<th id="jovi" rowspan="4">Jovian planets</th>
<th id="gas" rowspan="2">Gas giants</th>
<th id="jupi">Jupiter</th>
<td headers="jovi gas jupi mass">1898</td>
<td headers="jovi gas jupi diam">142,984</td>
<td headers="jovi gas jupi dens">1326</td>
<td headers="jovi gas jupi grav">23.1</td>
<td headers="jovi gas jupi lday">9.9</td>
<td headers="jovi gas jupi dist">778.6</td>
<td headers="jovi gas jupi temp">-110</td>
<td headers="jovi gas jupi moons">67</td>
<td headers="jovi gas jupi note">The largest planet</td>
</tr>
<tr>
<th id="saturn">Saturn</th>
<td headers="jovi gas saturn mass">568</td>
<td headers="jovi gas saturn diam">120,536</td>
<td headers="jovi gas saturn dens">687</td>
<td headers="jovi gas saturn grav">9.0</td>
<td headers="jovi gas saturn lday">10.7</td>
<td headers="jovi gas saturn dist">1433.5</td>
<td headers="jovi gas saturn temp">-140</td>
<td headers="jovi gas saturn moons">62</td>
<td headers="jovi gas saturn note"> </td>
</tr>
<tr>
<th id="ice" rowspan="2">Ice giants</th>
<th id="uran">Uranus</th>
<td headers="jovi ice uran mass">86.8</td>
<td headers="jovi ice uran diam">51,118</td>
<td headers="jovi ice uran dens">1271</td>
<td headers="jovi ice uran grav">8.7</td>
<td headers="jovi ice uran lday">17.2</td>
<td headers="jovi ice uran dist">2872.5</td>
<td headers="jovi ice uran temp">-195</td>
<td headers="jovi ice uran moons">27</td>
<td headers="jovi ice uran note"> </td>
</tr>
<tr>
<th id="nept">Neptune</th>
<td headers="jovi ice nept mass">102</td>
<td headers="jovi ice nept diam">49,528</td>
<td headers="jovi ice nept dens">1638</td>
<td headers="jovi ice nept grav">11.0</td>
<td headers="jovi ice nept lday">16.1</td>
<td headers="jovi ice nept dist">4495.1</td>
<td headers="jovi ice nept temp">-200</td>
<td headers="jovi ice nept moons">14</td>
<td headers="jovi ice nept note"> </td>
</tr>
<tr>
<th id="dwarf" colspan="2">Dwarf planets*</th>
<th id="pluto">Pluto</th>
<td headers="dwarf pluto mass">0.0146</td>
<td headers="dwarf pluto diam">2,370</td>
<td headers="dwarf pluto dens">2095</td>
<td headers="dwarf pluto grav">0.7</td>
<td headers="dwarf pluto lday">153.3</td>
<td headers="dwarf pluto dist">5906.4</td>
<td headers="dwarf pluto temp">-225</td>
<td headers="dwarf pluto moons">5</td>
<td headers="dwarf pluto note">Declassified as a planet in 2006, but this <a href="http://www.usatoday.com/story/tech/2014/10/02/pluto-planet-solar-system/16578959/">remains controversial</a>.</td>
</tr>
</tbody>
</table>
html {
font-family: sans-serif;
}
table {
border-collapse: collapse;
border: 2px solid rgb(200,200,200);
letter-spacing: 1px;
font-size: 0.8rem;
}
td, th {
border: 1px solid rgb(190,190,190);
padding: 10px 20px;
}
th {
background-color: rgb(235,235,235);
}
td {
text-align: center;
}
tr:nth-child(even) td {
background-color: rgb(250,250,250);
}
tr:nth-child(odd) td {
background-color: rgb(245,245,245);
}
caption {
padding: 10px;
}
Also see: Tab Triggers