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.
<input type="radio" id="animal" name="wiki" value="Animal" checked>
<input type="radio" id="plant" name="wiki" value="Plant">
<input type="radio" id="space" name="wiki" value="Space">
<input type="radio" id="river" name="wiki" value="River">
<ul class="accordion">
<li data-radio="animal">
<label for="animal" class="accordion-title">
<span>01</span>
<span class="accordion-heading">Animal</span>
</label>
<div class="accordion-content">Animals are multicellular eukaryotic organisms that form the biological kingdom Animalia. With few exceptions, animals consume organic material, breathe oxygen, are able to move, can reproduce sexually, and grow from a hollow sphere of cells, the blastula, during embryonic development. Over 1.5 million living animal species have been described—of which around 1 million are insects—but it has been estimated there are over 7 million animal species in total. Animals range in length from 8.5 millionths of a metre to 33.6 metres (110 ft). They have complex interactions with each other and their environments, forming intricate food webs. The kingdom Animalia includes humans, but in colloquial use the term animal often refers only to non-human animals. The study of non-human animals is known as zoology.</div>
</li>
<li data-radio="plant">
<label for="plant" class="accordion-title">
<span>02</span>
<span class="accordion-heading">Plant</span>
</label>
<div class="accordion-content">MPlants are mainly multicellular, predominantly photosynthetic eukaryotes of the kingdom Plantae. Historically, plants were treated as one of two kingdoms including all living things that were not animals, and all algae and fungi were treated as plants. However, all current definitions of Plantae exclude the fungi and some algae, as well as the prokaryotes (the archaea and bacteria). By one definition, plants form the clade Viridiplantae (Latin name for "green plants"), a group that includes the flowering plants, conifers and other gymnosperms, ferns and their allies, hornworts, liverworts, mosses and the green algae, but excludes the red and brown algae.</div>
</li>
<li data-radio="space">
<label for="space" class="accordion-title">
<span>03</span>
<span class="accordion-heading">Space</span>
</label>
<div class="accordion-content">Space is the boundless three-dimensional extent in which objects and events have relative position and direction. Physical space is often conceived in three linear dimensions, although modern physicists usually consider it, with time, to be part of a boundless four-dimensional continuum known as spacetime. The concept of space is considered to be of fundamental importance to an understanding of the physical universe. However, disagreement continues between philosophers over whether it is itself an entity, a relationship between entities, or part of a conceptual framework.</div>
</li>
<li data-radio="river">
<label for="river" class="accordion-title">
<span>04</span>
<span class="accordion-heading">River</span>
</label>
<div class="accordion-content">A river is a natural flowing watercourse, usually freshwater, flowing towards an ocean, sea, lake or another river. In some cases a river flows into the ground and becomes dry at the end of its course without reaching another body of water. Small rivers can be referred to using names such as stream, creek, brook, rivulet, and rill. There are no official definitions for the generic term river as applied to geographic features, although in some countries or communities a stream is defined by its size. Many names for small rivers are specific to geographic location; examples are "run" in some parts of the United States, "burn" in Scotland and northeast England, and "beck" in northern England. Sometimes a river is defined as being larger than a creek, but not always: the language is vague.</div>
</li>
</ul>
<footer class="page-footer">
<small>Made with <span>❤</span> by <a href="http://georgemartsoukos.com/" target="_blank">George Martsoukos</a>
</small>
</footer>
/* RESET RULES
–––––––––––––––––––––––––––––––––––––––––––––––––– */
:root {
--accordion-color: #282828;
--title-color: #191919;
--active-color: #3e86d2;
--separator-color: #292c2d;
--white: #9b9b9b;
--red: #e74c3c;
--black: #000;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
label {
cursor: pointer;
}
ul {
list-style: none;
}
a {
text-decoration: none;
color: inherit;
}
input[type="radio"] {
position: absolute;
left: -9999px;
}
body {
position: relative;
display: flex;
align-items: center;
min-height: 100vh;
padding: 50px 0;
font: 1rem/1.5 'Muli', sans-serif;
}
/* ACCORDION
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.accordion {
position: relative;
width: calc(100% - 20px);
max-width: 800px;
min-height: 380px;
margin: 0 auto;
background: var(--accordion-color);
color: var(--white);
}
.accordion::before {
content: 'Source: Wikipedia';
position: absolute;
right: 0;
top: -20px;
font-size: 0.8rem;
color: var(--black);
}
.accordion label {
text-align: center;
}
.accordion,
.accordion li,
.accordion .accordion-title {
display: flex;
}
.accordion li:not(:last-child) {
border: 1px solid var(--separator-color);
}
.accordion .accordion-title {
flex-direction: column;
justify-content: space-between;
width: 70px;
font-size: 1.4rem;
font-weight: bold;
line-height: normal;
padding: 20px 10px;
background: var(--title-color);
transition: color 0.1s;
}
.accordion .accordion-title:hover {
color: var(--active-color);
}
.accordion .accordion-heading {
display: inline-block;
white-space: nowrap;
transform-origin: bottom;
transform: rotate(-90deg) translate(50%, 50%);
}
.accordion .accordion-content {
display: none;
align-items: center;
justify-content: center;
flex-grow: 1;
padding: 20px;
}
[value="Animal"]:checked ~ .accordion [data-radio="animal"],
[value="Plant"]:checked ~ .accordion [data-radio="plant"],
[value="Space"]:checked ~ .accordion [data-radio="space"],
[value="River"]:checked ~ .accordion [data-radio="river"] {
flex-grow: 1;
}
[value="Animal"]:checked ~ .accordion [for="animal"] + .accordion-content,
[value="Plant"]:checked ~ .accordion [for="plant"] + .accordion-content,
[value="Space"]:checked ~ .accordion [for="space"] + .accordion-content,
[value="River"]:checked ~ .accordion [for="river"] + .accordion-content {
display: flex;
}
[value="Animal"]:checked ~ .accordion [for="animal"],
[value="Plant"]:checked ~ .accordion [for="plant"],
[value="Space"]:checked ~ .accordion [for="space"],
[value="River"]:checked ~ .accordion [for="river"] {
color: var(--active-color);
}
/*[value="Animal"]:focus ~ .accordion [for="animal"],
[value="Plant"]:focus ~ .accordion [for="plant"],
[value="Space"]:focus ~ .accordion [for="space"],
[value="River"]:focus ~ .accordion [for="river"] {
outline: 1px solid var(--active-color);
}*/
/* MQ
–––––––––––––––––––––––––––––––––––––––––––––––––– */
@media screen and (max-width: 650px) {
.accordion {
min-height: 0;
}
.accordion,
.accordion li {
flex-direction: column;
}
.accordion .accordion-title {
flex-direction: row;
width: auto;
}
.accordion .accordion-heading {
transform: none;
}
.accordion .accordion-title,
.accordion .accordion-content {
padding: 20px;
}
}
/* FOOTER
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.page-footer {
position: absolute;
bottom: 10px;
right: 10px;
font-size: 1rem;
color: var(--black);
}
.page-footer span {
color: var(--red);
}
Also see: Tab Triggers