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.
<button type="button" class="cc-modal__button--settings" onclick="openCCModal('cc-accept')" aria-label="cookie settings">
cookie
</button>
<div id="cc-accept" class="cc-modal">
<div role="dialog" class="cc-modal__dialog">
<div class="cc-modal__content">
<div class="cc-modal__header">
<h2>Deze website maakt gebruik van cookies</h2>
</div>
<div class="cc-modal__body">
<p>
Deze website maakt gebruik van cookies om de functionaliteit en effectiviteit te verbeteren. Sommige cookies worden geplaatst door diensten van derden. Door op ‘accepteren en doorgaan’ te klikken ga je akkoord met het gebruik van cookies zoals omschreven in onze privacyverklaring. Je kunt je eigen voorkeuren aanpassen door op ‘zelf instellen’ te klikken.</p>
<details>
<summary>Wat zijn cookies?</summary>
<div>
<p>Cookies zijn kleine tekstbestanden die door websites kunnen worden gebruikt om gebruikerservaringen efficiënter te maken.</p>
<p>Volgens de wet mogen wij cookies op jouw apparaat opslaan als ze strikt noodzakelijk zijn voor het gebruik van de site. Voor alle andere soorten cookies hebben we je toestemming nodig.</p>
<p>Deze website maakt gebruik van verschillende soorten cookies. Sommige cookies worden geplaatst door diensten van derden die op onze pagina's worden weergegeven.</p>
<p>Je kunt je toestemming op elk moment wijzigen of intrekken.</p>
</div>
</details>
</div>
<div class="cc-modal__footer">
<button id="cc-reject-all" class="cc-modal__button">Weiger</button>
<button onclick="openCCModal('cc-settings')" class="cc-modal__button">Zelf instellen</button>
<button id="cc-accept-all" class="cc-modal__button cc-modal__button--active">Accepteren</button>
</div>
</div>
</div>
<div id="cc-settings" class="cc-modal">
<div role="dialog" class="cc-modal__dialog">
<div class="cc-modal__content">
<div class="cc-modal__header">
<button class="cc-modal__button-close" onclick="closeCCModal('cc-settings')" aria-label="Close">X</button>
<h2>Cookie Settings</h2>
<p>Welke cookies mogen we plaatsen?</p>
</div>
<div class="cc-modal__body">
<h3>Noodzakelijke cookies</h3>
<p>Noodzakelijke cookies helpen een website bruikbaarder te maken, door basisfuncties als paginanavigatie en toegang tot beveiligde gedeelten van de website mogelijk te maken. Zonder deze cookies kan de website niet naar behoren werken.</p>
<label><input id="consent-necessary" type="checkbox" value="cookiesNecessary" checked disabled/>Noodzakelijke cookies (altijd aan)</label>
<hr/>
<h3>Persoonlijke instellingen</h3>
<p>Voorkeurscookies zorgen ervoor dat een website informatie kan onthouden die van invloed is op het gedrag en de vormgeving van de website, zoals de taal van je voorkeur of de regio waar je woont.</p>
<label><input id="consent-preferences" type="checkbox" value="cookiesPreferences" checked />Voorkeurscookies</label>
<hr/>
<h3>Statistische cookies</h3>
<p>Statistische cookies helpen eigenaren van websites begrijpen hoe bezoekers hun website gebruiken, door anoniem gegevens te verzamelen en te rapporteren.</p>
<label><input id="consent-analytics" type="checkbox" value="cookiesAnalytics" checked />Statistiche cookies</label>
<hr/>
<h3>Marketing cookies</h3>
<p>Marketingcookies worden gebruikt om bezoekers te volgen wanneer ze verschillende websites bezoeken. Hun doel is advertenties weergeven die zijn toegesneden op en relevant zijn voor de individuele gebruiker. Deze advertenties worden zo waardevoller voor uitgevers en externe adverteerders.</p>
<label><input id="consent-marketing" type="checkbox" value="cookiesMarketing" />Marketing cookies</label>
</div>
<div class="cc-modal__footer">
<button id="cc-accept-selection" class="cc-modal__button cc-modal__button--active">Settings opslaan</button>
</div>
</div>
</div>
</div>
</div>
.cc-modal {
position: fixed;
inset: 0;
z-index: 1050;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
outline: 0;
transition: opacity .15s linear;
font-size: 16px;
line-height: 1.5555555556;
font-weight: 400;
letter-spacing: normal;
background-color:rgba(20,20,20,.75);
font-family: system-ui, sans-serif;
}
.cc-modal:not(.open) {
display: none;
opacity: 0;
}
.cc-modal.open {
overflow-x: hidden;
overflow-y: auto;
}
.cc-modal h2 {
font-size: 2em;
}
.cc-modal .cc-modal__dialog {
transition: transform .3s ease-out;
transform: translate(0,-50px);
position: relative;
margin: 1.75em auto;
inline-size: calc(100% - 1em);
pointer-events: none;
max-inline-size: 42em;
max-block-size:80vh;
}
.cc-modal.open .cc-modal__dialog {
transform: none;
}
.cc-modal__content {
position: relative;
display: flex;
flex-direction: column;
inline-size: 100%;
pointer-events: auto;
background-color: #f8f9fa;
background-clip: padding-box;
border: 1px solid rgba(0,0,0,.2);
border-radius: 0.3em;
outline: 0;
}
.cc-modal__content > * {
padding: 1em;
}
.cc-modal__content > * > * {
margin-block: unset;
}
.cc-modal__header {
border-bottom: 1px solid;
}
.cc-modal__body > * + * {
margin-top: .5em;
}
.cc-modal__footer {
display: flex;
align-items: stretch;
gap: .5em;
border-top: 1px solid;
}
.cc-modal__button {
flex: 1;
color: #1a73e8;
background-color: #ffffff;
border: 1px solid #dadce0;
border-radius: .25em;
padding: 1em;
cursor: pointer;
transition: background-color .2s,box-shadow .2s,color .2s;
}
.cc-modal__button:hover,
.cc-modal__button:focus {
background-color: #f6f9fe;
border-color: #1a73e8;
color: #174ea6;
}
.cc-modal__button--active {
color: #ffffff;
background-color: #1a73e8;
border-color: #1a73e8;
}
.cc-modal__button--active:hover,
.cc-modal__button--active:focus {
box-shadow: 0 1px 2px 0 rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
background-color: #185abc;
color: #ffffff;
}
.cc-modal__button--settings {
position: fixed;
display: flex;
justify-content: center;
align-items: center;
inset-block-end: .5em;
inset-inline-start: .5em;
border: none;
background: transparent;
}
.cc-modal__button--settings svg {
inline-size: 1em;
block-size: 1em;
}
.cc-modal__button-close {
border: none;
background: transparent;
float: right;
}
.cc-modal details {
padding: .5em;
border: 1px solid #dadce0;
border-radius: .25em;
}
.cc-modal details summary {
cursor: pointer;
}
.cc-modal details summary > * {
display: inline;
}
details[open] summary {
border-bottom: 1px solid #dadce0;
margin-bottom: 0.5em;
}
.cc-modal details > div > * {
margin-bottom: unset;
}
.cc-modal details > div > * + * {
margin-top: .5em;
}
function openCCModal(id) {
document.getElementById(id).classList.add('open');
document.body.classList.add('cc-modal-open');
if (localStorage.getItem('consentMode') !== null) {
restoreFromLocalStorage();
}
}
// close currently open modal
function closeCCModal(id) {
document.getElementById(id).classList.remove('open');
document.body.classList.remove('cc-modal-open');
}
// close all open modals
function closeCCModals() {
document.querySelector('.cc-modal.open').classList.remove('open');
document.body.classList.remove('cc-modal-open');
}
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
// accept all cookies
function acceptAllCookies() {
setConsent(
{
adStorage: true,
analyticsStorage: true,
personalizationStorage: true,
functionalityStorage: true,
securityStorage: true,
adUserData: true,
adPersonalization: true
}
);
closeCCModals();
};
// accept selection
function acceptSelectedCookies() {
setConsent(
{
adStorage: document.getElementById('consent-marketing').checked,
analyticsStorage: document.getElementById('consent-analytics').checked,
personalizationStorage: document.getElementById('consent-preferences').checked,
functionalityStorage: document.getElementById('consent-preferences').checked,
securityStorage: true,
adUserData: document.getElementById('consent-marketing').checked,
adPersonalization: document.getElementById('consent-marketing').checked,
}
);
closeCCModals();
}
// accept only necessary
function acceptNoCookies() {
setConsent(
{
adStorage: false,
analyticsStorage: false,
personalizationStorage: false,
functionalityStorage: false,
securityStorage: true,
adUserData: false,
adPersonalization: false
}
);
closeCCModals();
}
// set consent
function setConsent(consent) {
var consentMode = {
'ad_storage': consent.adStorage ? 'granted' : 'denied',
'analytics_storage': consent.analyticsStorage ? 'granted' : 'denied',
'personalization_storage': consent.personalizationStorage ? 'granted' : 'denied',
'functionality_storage': consent.functionalityStorage ? 'granted' : 'denied',
'security_storage': consent.securityStorage ? 'granted' : 'denied',
'ad_user_data': consent.adUserData ? 'granted' : 'denied',
'ad_personalization': consent.adPersonalization ? 'granted' : 'denied',
};
gtag('consent', 'update', consentMode);
localStorage.setItem('consentMode', JSON.stringify(consentMode));
dataLayer.push({event: 'cookie_consent_update'});
}
// load settings
function restoreFromLocalStorage() {
var consent = JSON.parse(localStorage.getItem('consentMode'));
if (consent.adStorage === 'granted'
|| consent.adUserData === 'granted'
|| consent.adPersonalization === 'granted') {
document.getElementById('consent-marketing').setAttribute('checked', 'checked')
}
if (consent.analyticsStorage === 'granted') {
document.getElementById('consent-analytics').setAttribute('checked', 'checked')
}
if (consent.personalizationStorage === 'granted'
|| consent.functionalityStorage === 'granted') {
document.getElementById('consent-preferences').setAttribute('checked', 'checked')
}
if (consent.securityStorage === 'granted') {
document.getElementById('consent-necessary').setAttribute('checked', 'checked')
}
}
// Store the cookie preferences into local storage
if (localStorage.getItem('consentMode') === null) {
document.getElementById('cc-accept').classList.add('open');
}
document.getElementById('cc-accept-all').addEventListener('click', function (ev) {
acceptAllCookies()
});
document.getElementById('cc-accept-selection').addEventListener('click', function (ev) {
acceptSelectedCookies();
});
document.getElementById('cc-reject-all').addEventListener('click', function (ev) {
acceptNoCookies();
});
Also see: Tab Triggers