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.
<form id="search_form">
<label for="search_input">Search a word</label>
<input id="search_input" type="text">
<button type="submit">Submit</button>
</form>
<div id="result"></div>
import FuzzySearch from 'https://unpkg.com/[email protected]/src/FuzzySearch.js'
const entries = data();
const fzf = new FuzzySearch(Object.keys(entries), [], {
caseSensitive: false,
sort: true
});
const search = create_search(entries, true);
const search_name = create_search(entries, false);
const update_input = val => (window.search_form[0].value = val);
const suggest_word = value => () =>
suggest(value)
.filter(confirm_word)
.tap(update_input)
.map(search);
const search_word = word =>
search(word)
.or_else(() => search_name(word))
.or_else(suggest_word(word))
.map(format)
.unwrap_or('word not found');
window.search_form.addEventListener('submit', function(ev) {
ev.preventDefault();
window.result.innerHTML = search_word(ev.target[0].value);
});
// Utilities
function create_search(data, exact) {
return input => {
const word = exact ? input : capitalize(input);
return Maybe(data[word]);
};
}
function suggest(word) {
const matches = fzf.search(word);
return Maybe(matches[0]);
}
function confirm_word(value) {
return confirm(`Did you mean ${value}`);
}
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
function format(results) {
return results.join('<br>');
}
function Maybe(the_thing) {
if (the_thing === null || the_thing === undefined || the_thing.is_nothing) {
return Nothing();
}
if (the_thing.is_just) {
return the_thing;
}
return Just(the_thing);
}
function Just(thing) {
return {
map: fun => Maybe(fun(thing)),
and_then: fun => fun(thing),
or_else: () => Just(thing),
tap: fun => (fun(thing), Just(thing)),
unwrap_or: () => thing,
filter: predicate_fun => (predicate_fun(thing) ? Maybe(thing) : Nothing()),
is_just: true,
is_nothing: false,
inspect: () => `Just(${thing})`
};
}
function Nothing() {
return {
map: Nothing,
and_then: Nothing,
or_else: fun => fun(),
tap: Nothing,
unwrap_or: arg => arg,
filter: Nothing,
is_just: false,
is_nothing: true,
inspect: () => `Nothing`
};
}
// what are you doing here? Get out!!
function data() {
return {
"abandoned industrial site": ["Site that cannot be used for any purpose, being contaminated by pollutants."],
"abandoned vehicle": ["A vehicle that has been discarded in the environment, urban or otherwise, often found wrecked, destroyed, damaged or with a major component part stolen or missing."],
"abiotic factor": ["Physical, chemical and other non-living environmental factor."],
"access road": ["Any street or narrow stretch of paved surface that leads to a specific destination, such as a main highway."],
"access to the sea": ["The ability to bring goods to and from a port that is able to harbor sea faring vessels."],
"accident": ["An unexpected, unfortunate mishap, failure or loss with the potential for harming human life, property or the environment.", "An event that happens suddenly or by chance without an apparent cause."],
"accumulator": ["A rechargeable device for storing electrical energy in the form of chemical energy, consisting of one or more separate secondary cells.\\n(Source: CED)"],
"acidification": ["Addition of an acid to a solution until the pH falls below 7."],
"acidity": ["The state of being acid that is of being capable of transferring a hydrogen ion in solution."],
"acidity degree": ["The amount of acid present in a solution, often expressed in terms of pH."],
"acid rain": ["Rain having a pH less than 5.6."],
"acid": ["A compound capable of transferring a hydrogen ion in solution.", "Being harsh or corrosive in tone.", "Having an acid, sharp or tangy taste.", "A powerful hallucinogenic drug manufactured from lysergic acid.", "Having a pH less than 7, or being sour, or having the strength to neutralize alkalis, or turning a litmus paper red."],
"acoustic filter": ["A device employed to reject sound in a particular range of frequencies while passing sound in another range of frequencies."],
"acoustic insulation": ["The process of preventing the transmission of sound by surrounding with a nonconducting material."],
"acoustic level": ["Physical quantity of sound measured, usually expressed in decibels.\\n(Source: KORENa)"],
"Paris": ["The capital and largest city of France."]
};
}
Also see: Tab Triggers