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.
<main>
<h1>Pure CSS Accordion</h1>
<div class="accordion">
<input type="radio" name="accordion" id="accordion-1" checked="">
<label for="accordion-1">Accordion One</label>
<div class="accordion-content">
<p><b>Accordion Content - 1</b></p>
<p>Made using pseudo selector radio inputs:checked + labels for tabs, and + selector to target adjacent siblings accordion content.</p>
<p>*Remove checked="" on the first accordion if you want to start with a fully closed accordion.</p>
<p>Super simple, and easy to modify for your own needs.</p>
</div>
<input type="radio" name="accordion" id="accordion-2">
<label for="accordion-2">Accordion Two</label>
<div class="accordion-content">
<p><b>Accordion Content - 2</b></p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit.<br/>Fugit deserunt aliquam quia dicta qui natus error aut molestiae nostrum nihil possimus iure, veniam architecto aspernatur id nulla, incidunt ducimus suscipit.</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Fugit deserunt aliquam quia dicta qui natus error aut molestiae nostrum </p>
</div>
<input type="radio" name="accordion" id="accordion-3">
<label for="accordion-3">Accordion Three</label>
<div class="accordion-content">
<p><b>Accordion Content - 3</b></p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Fugit deserunt aliquam quia dicta qui natus error aut molestiae nostrum nihil possimus iure, veniam architecto.</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Fugit deserunt aliquam quia dicta qui natus error aut molestiae nostrum nihil possimus iure, veniam architecto.Lorem ipsum dolor sit amet consectetur adipisicing elit.</p>
</div>
</div>
</main>
<footer>
<p>Developed by Stephen Fray 🏄 | <a href="https://codepen.io/stepfray" target="_blank" rel="noreferrer" title="View My Code Pen Profile">CodePen</a> | <a href="https://www.behance.net/stephen_fray" arget="_blank" rel="noreferrer" title="View my Behance Profile">Behance</a></p>
</footer>
////////////////////
// Colour Vars
////////////////////
$light: #eee;
$light-shade-2: #ccc;
$light-shade-3: #bababa;
$dark: #444444;
////////////////////
// Accordion
////////////////////
.accordion {
display: flex;
flex-direction: column;
flex-wrap: wrap;
}
////////////////////
// Accordion -- Hide Radios Inputs
////////////////////
.accordion input[type="radio"] {
display: none;
}
////////////////////
// Accordion -- Section Titles (labels)
////////////////////
.accordion label {
padding: 0.3em 1em;
cursor: pointer;
display: inline-flex;
&:not(:last-of-type) {
border-bottom: 1px solid $light-shade-3;
}
&:first-of-type {
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
&:last-of-type {
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
}
.accordion label {
user-select: none;
background-color: $light-shade-2;
}
.accordion label:hover {
background: $light-shade-2;
}
.accordion input:checked + label {
background: $light-shade-2;
border-bottom: 1px solid $light;
&:last-of-type {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
}
////////////////////
// Accordion -- Content
////////////////////
.accordion-content {
background-color: $light;
overflow: hidden;
&:last-of-type {
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
p {
margin-bottom: 0;
&:first-of-type {
margin-top: 0;
}
}
}
////////////////////
// Accordion -- Show/Hide Content
////////////////////
.accordion-content {
max-height: 0;
visibility: hidden;
transition: all 0.8s;
padding: 0 1.2em;
* {
opacity: 0;
transition: opacity 0.8s;
}
}
.accordion input[type="radio"]:checked + label + .accordion-content {
max-height: 100vh;
visibility: visible;
opacity: 1;
padding: 1.2em;
* {
opacity: 1;
}
}
////////////////////
// Page Set Up - Ignore
////////////////////
* {
box-sizing: border-box;
}
body {
color: $dark;
display: grid;
place-content: center;
padding: 0;
margin: 0;
min-height: 100vh;
background-image: #99c5ff;
background-image: radial-gradient(
at 32% 10%,
hsla(29, 95%, 71%, 1) 0,
transparent 52%
),
radial-gradient(at 46% 54%, hsla(179, 98%, 69%, 1) 0, transparent 47%),
radial-gradient(at 33% 9%, hsla(199, 73%, 71%, 1) 0, transparent 53%),
radial-gradient(at 63% 58%, hsla(200, 77%, 77%, 1) 0, transparent 52%),
radial-gradient(at 60% 91%, hsla(45, 70%, 78%, 1) 0, transparent 56%),
radial-gradient(at 14% 87%, hsla(297, 77%, 69%, 1) 0, transparent 51%),
radial-gradient(at 81% 56%, hsla(309, 85%, 62%, 1) 0, transparent 40%),
radial-gradient(at 70% 57%, hsla(261, 98%, 77%, 1) 0, transparent 40%),
radial-gradient(at 37% 48%, hsla(260, 85%, 60%, 1) 0, transparent 54%),
radial-gradient(at 54% 28%, hsla(230, 77%, 69%, 1) 0, transparent 56%),
radial-gradient(at 22% 83%, hsla(54, 91%, 76%, 1) 0, transparent 58%),
radial-gradient(at 58% 34%, hsla(170, 96%, 62%, 1) 0, transparent 58%),
radial-gradient(at 43% 93%, hsla(59, 92%, 79%, 1) 0, transparent 42%),
radial-gradient(at 3% 23%, hsla(125, 72%, 78%, 1) 0, transparent 41%),
radial-gradient(at 77% 92%, hsla(24, 82%, 64%, 1) 0, transparent 58%),
radial-gradient(at 62% 97%, hsla(53, 87%, 72%, 1) 0, transparent 54%),
radial-gradient(at 84% 48%, hsla(133, 81%, 78%, 1) 0, transparent 42%);
/// Background by Mesher
/// Spread the love: https://www.csshero.org/mesher/
font-family: apple-system, sans-serif;
font-size: 18px;
line-height: 1.5;
padding-bottom: 50vh;
}
main {
max-width: 700px;
margin: auto;
padding: clamp(15px, 2vw, 60px);
}
h1 {
font-size: clamp(1.5rem, 7vw, 2.5rem);
}
p {
font-size: clamp(0.9rem, 3vw, 1.1rem);
}
label {
font-size: clamp(1rem, 3vw, 1.4rem);
}
footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
text-align: center;
background-color: rgba(255, 255, 255, 0.5);
padding: 10px;
z-index:9999999;
p {
font-size: 0.8rem;
margin: 0;
}
}
Also see: Tab Triggers