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.
<!doctype html>
<html>
<head>
<script type="text/javascript">
var _iub = _iub || [];
_iub.csConfiguration = {
"lang": "en",
"siteId": 896537, //use your siteId
"cookiePolicyId": 8207462, //use your cookiePolicyId
"consentOnContinuedBrowsing": false, //avoid to collect consent by scrolling and continued browsing activity
"perPurposeConsent": true,
"banner": {
"acceptButtonDisplay": true,
"closeButtonRejects": true,
"customizeButtonDisplay": true,
"explicitWithdrawal": true,
"listPurposes": true,
"position": "float-top-center",
"rejectButtonDisplay": true
},
//some (optional) callbacks that our Cookie Solution can perform upon the occurrence of an event
callback: {
"onConsentGiven": function() {
//invoked if the user has given the consent to the installation of cookies
log('onConsentGiven');
},
"onConsentRejected": function() {
//invoked if the user has rejected the consent to the installation of cookies
log('onConsentRejected');
},
"onPreferenceExpressed": function(preference) {
//fires whenever a preference is expressed, be it accept or reject
log('onPreferenceExpressed(' + JSON.stringify(preference) + ')');
}
}
};
</script>
<script type="text/javascript" src="//cdn.iubenda.com/cs/iubenda_cs.js" charset="UTF-8" async></script>
</head>
<body>
<header>
<div class="wrapper">
<h1>iubenda Cookie Solution</h1>
<p>Per-category consent</p>
</div>
</header>
<section class="wrapper">
<p>This is one of the possible setups of our Cookie Solution: it's essentially the default configuration except for consent on continued browsing (disabled here), and the addition of the <a href="https://codepen.io/iubenda/pen/QWWEdQj/left?editors=1000" target="_blank">reject button</a> and <strong>per-category consent</strong>.</p>
<p>This feature gives users granular control on which categories of cookies or other identifiers to give consent to:</p>
<div class="scripts">
<ul>
<li>Strictly necessary (purpose id 1): <span id="pur-1" class="activated">activated</span> (no consent required)</li>
<li>Basic interactions & functionalities (purpose id 2): <span id="pur-2">blocked</span></li>
<li>Experience enhancement (purpose id 3): <span id="pur-3">blocked</span></li>
<li>Measurement (purpose id 4): <span id="pur-4">blocked</span></li>
<li>Targeting & Advertising (purpose id 5): <span id="pur-5">blocked</span></li>
<li>Scripts with purposes 2 and 5: <span id="pur-2-5">blocked</span></li>
</ul>
</div>
<div id="logs"></div>
<script type="plain/text" class="_iub_cs_activate" data-iub-purposes="1">
document.getElementById('pur-1').innerHTML = 'activated';
document.getElementById('pur-1').className = 'activated'
</script>
<script type="plain/text" class="_iub_cs_activate" data-iub-purposes="2">
document.getElementById('pur-2').innerHTML = 'activated';
document.getElementById('pur-2').className = 'activated';
</script>
<script type="plain/text" class="_iub_cs_activate" data-iub-purposes="3">
document.getElementById('pur-3').innerHTML = 'activated';
document.getElementById('pur-3').className = 'activated';
</script>
<script type="plain/text" class="_iub_cs_activate" data-iub-purposes="4">
document.getElementById('pur-4').innerHTML = 'activated';
document.getElementById('pur-4').className = 'activated';
</script>
<script type="plain/text" class="_iub_cs_activate" data-iub-purposes="5">
document.getElementById('pur-5').innerHTML = 'activated';
document.getElementById('pur-5').className = 'activated';
</script>
<script type="plain/text" class="_iub_cs_activate" data-iub-purposes="2,5">
document.getElementById('pur-2-5').innerHTML = 'activated';
document.getElementById('pur-2-5').className = 'activated';
</script>
<p>The categories are displayed along with a short description and toggle so that users can either grant or reject consent for the particular processing purpose. The categories displayed in the modal are automatically detected, but they can also be customized by using the <code>purposes</code> parameter or through the configurator (see the <a href="https://codepen.io/iubenda/pen/zYYJwYr/left?editors=1000" target="_blank">dedicated demo</a>).</p>
<div class="tip">
<p>💡 Click on the "Learn more and customize" button to see this feature in action. Grant consent to the "Experience enhancement" category to release the YouTube and Twitter scripts below.</p>
</div>
<p>On the configurator:</p>
<img src="https://help.iubenda.com/wp-content/uploads/2020/02/cs-per-category-consent-codepen.png" width="480" />
<p>More options available in the Advanced View.</p>
<div class="note">
<ul>
<li>Remember to use your own credentials from <a href="https://www.iubenda.com/en/dashboard" target="_blank">your iubenda account</a></li>
<li>This is a sample for pure demonstrative purposes, <strong>no consents are saved</strong> (result of <code>_iub.csConfiguration.skipSaveConsent = true</code>). Just refresh the page to make the cookie banner reappear.</li>
<li><strong>If you don't see the cookie banner on your first visit</strong>, you may have a consent cookie saved from another demo: <a href="#" onclick="_iub.cs.cookie.resetCookies({local: true,remote: true});alert('Consent cookie deleted. Now click on OK and refresh the page to return to the starting point.')">reset consent</a> and refresh the page to make the cookie banner reappear.</li>
</ul>
</div>
<h3>Block cookies prior to consent</h3>
<p>To demonstrate the cookie blocking feature, we've embed a YouTube video:</p>
<div class="embed-container" -->
<!-- please note type="text/plain" class="_iub_cs_activate" data-suppressedsrc="..." (manual tagging) and data-iub-purposes="3" (per-category consent) -->
<iframe type="text/plain" class="_iub_cs_activate" width="560" height="315" data-suppressedsrc="https://www.youtube.com/embed/DS7bqHoz8Ic" data-iub-purposes="3" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<p>And a Twitter follow button:</p>
<!-- please note type="text/plain" class="_iub_cs_activate" data-suppressedsrc="..." (manual tagging) and data-iub-purposes="3" (per-category consent) -->
<a href="https://twitter.com/iubenda" class="twitter-follow-button" data-show-count="true" data-size="large">Follow @iubenda</a>
<script async type="text/plain" class="_iub_cs_activate" data-suppressedsrc="https://platform.twitter.com/widgets.js" data-iub-purposes="3" charset="utf-8"></script>
<p>Both scripts are blocked through <a href="https://www.iubenda.com/en/help/1229">manual tagging</a>, one of the <a href="https://www.iubenda.com/en/help/3081" target="_blank">methods available</a> with the Cookie Solution.</p>
<p>Since both the YouTube video widget and the Twitter follow button are part of the <strong>Experience enhancement</strong> purpose (id <code>3</code>), we've added <code>data-iub-purposes="3"</code> to their scripts so that the Cookie Solution can properly identify them for release.</p>
<p>Click on the <strong>Accept</strong> button - or just activate the "Experience enhancement" toggle - to release these scripts (refresh the page to return to the starting point).</p>
<hr />
<h3>Learn more</h3>
<div class="tip">
<p>Read our <a href="https://www.iubenda.com/en/help/1205#per-category-consent" target="_blank">advanced guide</a> for more information about per-category consent (including manual tagging, Google Tag Manager and WordPress plugin blocking methods).</p>
</div>
<p>Other helpful resources:</p>
<ul class="guides">
<li><a href="https://www.iubenda.com/en/help/1177" target="_blank">Cookie Solution - Getting Started</a></li>
<li><a href="https://www.iubenda.com/en/help/3831" target="_blank">How to Customize the Look and Behavior of the Cookie Banner (Beginner's Guide)</a></li>
<li><a href="https://www.iubenda.com/en/help/1205" target="_blank">How to Configure Your Cookie Solution (Advanced Guide)</a></li>
<li><a href="https://www.iubenda.com/en/help/3081" target="_blank">Introduction to the Prior Blocking of Cookies</a></li>
</ul>
</section>
</body>
</html>
//don't copy this JS (just for demo purposes)
//don't save consent, always show the banner
_iub.csConfiguration.skipSaveConsent = true;
//per-category logs
/*
function log(text) {
var p = document.createElement('p');
p.innerText = text;
document.querySelector('#logs').appendChild(p);
}
window.onerror = function(err) {
log('ERROR: ' + err);
}
*/
Also see: Tab Triggers