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.
<html>
<head>
<title>Home Questionnaire</title> <span id="selection-marker-1" class="redactor-selection-marker"></span>
</head>
<body>
<h1>What is your favorite place to travel?</h1>
<p>I am building a directory of the sweetest travel destinations.</p>
<form name="travel" onsubmit="identify(event)">
What is your favorite travel destination?
<input name="destination" required="" size="81" type="text"/>
<br><br><br>
Any recommendations (cool things to do, places to visit or restaurants to eat)?
<br><br>
<textarea cols="81" name="details" required="" rows="10">
</textarea>
<br><br>
Name: <input name="fullname" required="" size="75" type="text"/>
<br><br>
Email: <input name="email" required="" size="75" type="email"/>
<br><br>
<input name="submit" type="submit" value="submit"/>
</form>
<!-- Div Below is where consent manager will be injected to -->
<div id="target-container"></div>
</body>
</html>
//code below loads consentManagerConfig object and specifies content popup contains. Need to update with your own writeKey and what container code should be injected to, I am using empyty div
//note, may need to view demo in debug mode to save tracking preferences in browser
window.consentManagerConfig = function(exports) {
//creating our custome category object
var customCategories = {
'Analytics': {
integrations: ['Google Analytics','Mixpanel','Amplitude'],
purpose: 'Provide statistical information on site usage, e.g., web analytics so we can improve this website over time.'
},
'Functional': {
integrations: ['Salesforce Marketing Cloud','Visual Tagger'],
purpose: 'Enables enhanced functionality, such as videos and live chat. If you do not allow these, then some or all of these functions may not work properly.'
},
'Do Not Sell': {
integrations: ['Salesforce', 'MailChimp', 'AdWords'],
purpose:'To give the right to opt out of the sale of personal data.'
}
};
//this will set which category of tools are opted in/out of by default
var initialPrefs = {
'Functional': true,
'Analytics': false,
'Do Not Sell': false };
var prefs = {
container: '#target-container',
//passing in our customCategories object to consentManagerConfig
customCategories: customCategories,
//passing in our initial preferences object to consentManagerConfig
initialPreferences: initialPrefs,
writeKey: 'VuOZbPNXuR76IXTQeYaU6twg3qpSNAw9',
bannerContent: 'User consent is awesome! We use cookies (and other similar technologies) to collect data to improve your experience on our site.',
bannerSubContent: 'You can change your preferences at any time.',
cancelDialogContent: 'Your preferences have not been saved. By continuing to use our website, you are agreeing to our Website Data Collection Policy',
cancelDialogTitle: 'Are you sure you want to cancel?',
closeBehavior: 'accept',
implyConsentOnInteraction: false,
preferencesDialogContent: 'We use data collected by cookies and JavaScript libraries, which are necessary for website functioning, to improve user’s browsing experience, analyze site traffic, deliver personalized advertisements, and increase the overall performance of our site.',
preferencesDialogTitle: 'Website Data Collection Preferences'
}
return prefs;
}
</script>
<!--script that loads Prebuilt Consent Manager UI via Preact, note using version 5.0.0-->
<script src="https://unpkg.com/@segment/[email protected]/standalone/consent-manager.js" defer> </script>
<!--Load Analytics.js-->
<script>
!(function() {
var analytics = (window.analytics = window.analytics || [])
if (!analytics.initialize)
if (analytics.invoked)
window.console && console.error && console.error('Segment snippet included twice.')
else {
analytics.invoked = !0
analytics.methods = [
'trackSubmit',
'trackClick',
'trackLink',
'trackForm',
'pageview',
'identify',
'reset',
'group',
'track',
'ready',
'alias',
'debug',
'page',
'once',
'off',
'on',
//methods below needed for consent manager version 5.0.0 and greater!!
'addSourceMiddleware',
'addDestinationMiddleware'
]
analytics.factory = function(t) {
return function() {
var e = Array.prototype.slice.call(arguments)
e.unshift(t)
analytics.push(e)
return analytics
}
}
for (var t = 0; t < analytics.methods.length; t++) {
var e = analytics.methods[t]
analytics[e] = analytics.factory(e)
}
analytics.load = function(t, e) {
var n = document.createElement('script')
n.type = 'text/javascript'
n.async = !0
n.src =
('https:' === document.location.protocol ? 'https://' : 'http://') +
'cdn.segment.com/analytics.js/v1/' +
t +
'/analytics.min.js'
var o = document.getElementsByTagName('script')[0]
o.parentNode.insertBefore(n, o)
analytics._loadOptions = e
}
analytics.SNIPPET_VERSION = '4.1.0'
analytics.page()
}
})()
</script>
<!--Javascript that controls form submits and mapping user input data to Segment Analytics.js methods-->
<script type="text/javascript">
function identify(e){
e.preventDefault();
var form = e.target;
var email = form["email"].value;
var fullname = form["fullname"].value;
var destination = form["destination"].value;
var details = form["details"].value;
var user = {
email: email,
name: fullname,
destination: destination,
details: details
};
analytics.identify('1234', {
email: email,
name: fullname
});
analytics.track('destination submitted', user, function() {
window.location.href = "";
});
analytics.page('Home', user, {
url: "/"
});
analytics.alias('507f191e81');
analytics.group("0e8c78ea9d97a7b8185e8632", {
name: "Initech",
industry: "Technology",
employees: 329,
plan: "enterprise",
"total billed": 830
});
}
Also see: Tab Triggers