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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
<div id="content">
<h1>Making the <code><cite></code> tag sane</h1>
Simple citations is a script to generate a list of citations from citations within the the article. <cite data-source="https://webkit.org/blog/41/introducing-the-web-inspector/" data-date="01/16/06" data-title="Webkit.org - Introducing the Web Inspector"></cite> Each citation uses the under-utilized <code><cite><cite></code> tag. <cite data-source="https://www.w3schools.com/tags/tag_cite.asp" data-title="w3schools - cite" data-date="10/10/18"></cite> <cite data-source="http://www.google.com" data-title="google.com" data-date="10/10/18"></cite> It can even detect duplicate citings as long as the URL is the same.<cite data-source="https://webkit.org/blog/41/introducing-the-web-inspector/" data-date="01/16/06" data-title="Webkit.org - Introducing the Web Inspector"></cite> Each <code><cite></code> tag requires a <code>data-date</code>, <code>data-title</code>, and <code>date-source</code>. Somewhere in the article you will a blank <code><div><div></code> with an identifer (class or ID) for the list of sources to be stashed in. I realize there's far more robust plugins for this, but I wanted something light-weight and easy to manage.
<p>Filler text. In 1985 Aldus Corporation launched its first desktop publishing program Aldus PageMaker for Apple Macintosh computers, released in 1987 for PCs running Windows 1.0. Both contained the variant lorem ipsum most common today. Laura Perry, then art director with Aldus, modified prior versions of Lorem Ipsum text from typographical specimens; in the 1960s and 1970s it appeared often in lettering catalogs by Letraset. Anecdotal evidence has it that Letraset used Lorem ipsum already from 1970 onwards, eg. for grids (page layouts) for ad agencies. Many early desktop publishing programs, eg. Adobe PageMaker, used it to create template.
<p>Do you like Cheese Whiz? Spray tan? Fake eyelashes? That's what is Lorem Ipsum to many—it rubs them the wrong way, all the way. It's unreal, uncanny, makes you wonder if something is wrong, it seems to seek your attention for all the wrong reasons. Usually, we prefer the real thing, wine without sulfur based preservatives, real butter, not margarine, and so we'd like our layouts and designs to be filled with real words, with thoughts that count, information that has value.
<p>The toppings you may chose for that TV dinner pizza slice when you forgot to shop for foods, the paint you may slap on your face to impress the new boss is your business. But what about your daily bread? Design comps, layouts, wireframes—will your clients accept that you go about things the facile way? Authorities in our business will tell in no uncertain terms that Lorem Ipsum is that huge, huge no no to forswear forever. Not so fast, I'd say, there are some redeeming factors in favor of greeking text, as its use is merely the symptom of a worse problem to take into consideration.
<p>You begin with a text, you sculpt information, you chisel away what's not needed, you come to the point, make things clear, add value, you're a content person, you like words. Design is no afterthought, far from it, but it comes in a deserved second. Anyway, you still use Lorem Ipsum and rightly so, as it will always have a place in the web workers toolbox, as things happen, not always the way you like it, not always in the preferred order. Even if your less into design and more into content strategy you may find some redeeming value with, wait for it, dummy copy, no less.
<div id="citations"></div>
</div>
cite { font-size: 11px; padding-right: 3px;}
#citations {font-size: 11px; margin-top: 2em;
span { padding-right: 1em;}
}
code { color: lightgreen}
//formatting
#content { max-width: 800px; margin-left: auto; margin-right: auto; margin-top: 3em; padding-left: 1em; padding-right: 1em;}
html { background-color: #222; color: #eee; font-family: 'Noto Serif SC', serif; line-height: 1.4em; padding-bottom: 1em;
a {
color: orange;
}
-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1 { line-light: 1.3em}
let i = 0; // set the counter's starting point
let citeArray = [];
let citer = {
init: (target) => {
citer.createArray();
citer.writeToDOM(target);
},
createArray: () => {
$("cite").each( function() { //fat arrow make jQuery this goof
i = i + 1; //citations do not start at 0
let newObj = {
date : $(this).data("date"),
title: $(this).data("title"),
source: $(this).data("source"),
i: i
}
let duplicate = citer.checkDuplicates(newObj);
if (duplicate === false) { //only push new instance if URL is different
citeArray.push(newObj);
}
});
},
writeToDOM: (target) => {
citeArray.forEach( (instance) => {
const subcite = `<a href="#cite${instance.i}">${instance.i}</a>`;
const citation = `<a href="${instance.source}" id="cite${instance.i}">${instance.i} ${instance.title}</a> <span>${instance.date}</span>`
$(`[data-source="${instance.source}"]`).html(subcite);
$(target).append(citation);
});
},
checkDuplicates: (newObj) => {
let duplicate = false;
citeArray.forEach( (instance) => {
if ( instance.source === newObj.source ) {
duplicate = true;
}
});
return duplicate;
}
}
citer.init("#citations");
Also see: Tab Triggers