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>
<!-- Google Tag Manager -->
<script>
(function(w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({
'gtm.start': new Date().getTime(),
event: 'gtm.js'
});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-KJ2TH74');
</script>
<!-- End Google Tag Manager -->
<script type="text/javascript">
var _iub = _iub || [];
_iub.csConfiguration = {
lang: 'en',
siteId: 896537, //use your siteId
cookiePolicyId: 8207462, //use your cookiePolicyId
enableCcpa: true,
ccpaApplies: true,
enableGdpr: true,
gdprAppliesGlobally: false,
gdprApplies: true,
perPurposeConsent: true,
timeoutLoadConfiguration: 30000,
consentOnScroll: false, //avoid consent to be given when the user scrolls the page
banner: {
position: 'float-top-center',
acceptButtonDisplay: true,
customizeButtonDisplay: true,
rejectButtonDisplay: true,
},
callback: {
onPreferenceExpressedOrNotNeeded: function(preference) {
dataLayer.push({
iubenda_ccpa_opted_out: _iub.cs.api.isCcpaOptedOut()
});
if (!preference) {
dataLayer.push({
event: "iubenda_preference_not_needed"
});
} else {
if (preference.consent === true) {
dataLayer.push({
event: "iubenda_consent_given"
});
} else if (preference.consent === false) {
dataLayer.push({
event: "iubenda_consent_rejected"
});
} else if (preference.purposes) {
for (var purposeId in preference.purposes) {
if (preference.purposes[purposeId]) {
dataLayer.push({
event: "iubenda_consent_given_purpose_" + purposeId
});
}
}
}
}
}
}
};
</script>
<script async src="//cdn.iubenda.com/cs/iubenda_cs.js"></script>
</head>
<body>
<header>
<div class="wrapper">
<h1>iubenda Cookie Solution</h1>
<p>Google Tag Manager integration for CCPA, GDPR and per-category consent</p>
</div>
</header>
<section class="wrapper">
<p>💡 Click on "Accept", "Reject", "Learn more and customize" and "Do Not Sell My Personal Information" to customize your consent preferences for cookies.</p>
<div class="scripts">
<div class="script" id="no-purpose"> No Purpose</div>
<div class="script" id="no-purpose-sells"> No Purpose - Sale (to be blocked when CCPA opted out)</div>
<div class="script" id="purpose-1"> Strictly Necessary (no consent required)</div>
<div class="script" id="purpose-2"> Basic Interactions & Functionalities</div>
<div class="script" id="purpose-3"> Experience Enhancement</div>
<div class="script" id="purpose-4"> Analytics</div>
<div class="script" id="purpose-4-sells"> Analytics - Sale (to be blocked when CCPA opted out)</div>
<div class="script" id="purpose-5"> Targeting & Advertising</div>
</div>
<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>
</ul>
</div>
<h3>Learn more</h3>
<div class="tip">
<p>Read the guide <a href="https://www.iubenda.com/en/help/1235" target="_blank">How to Use Google Tag Manager to Simplify the Blocking of Cookies</a> for more information about additional settings.</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/21165" target="_blank">CCPA: How to add a notice of collection and a "Do not sell" link</a></li>
</ul>
</section>
</body>
</html>
/* don't copy this CSS (just for demo purposes) */
div.scripts .script {
border-bottom: 1px solid #D5D5D5;
margin-bottom: -1px;
padding: 14px 6px;
}
div.scripts .script:last-of-type {
border-bottom: none;
}
div.scripts .script:before {
content: '🚫';
}
div.scripts .script.activated:before,
div#purpose-1:before {
content: '✅';
}
//don't copy this JS (just for demo purposes)
//don't save consent, always show the banner
_iub.csConfiguration.skipSaveConsent = true;
// for testing purposes only to avoid setting the CCPA cookie
_iub.csConfiguration.callback.onCcpaOptOut = _iub.csConfiguration.callback.onCcpaAcknowledged = function() {
setTimeout(function() {
_iub.cs.cookie.resetLocalCookie('usprivacy');
});
};
Also see: Tab Triggers