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.
<div class="example">
<div class="editor" contenteditable spellcheck="false" role="textbox" aria-multiline="true">
<h1 id="p1">Priority 1</h1>
<p>The word <span role="mark">fish</span> is highlighted.</p>
<p>The word <mark class="commented-text" aria-details="thread-1">cat</mark> has a comment tied to it.</p>
<p>Suggestion: We shall eat <span role="suggestion" aria-details="thread-2"><del>oranges</del><ins>clementines</ins></span>.</p>
<p>Revision 1 has some text <del>removed</del>, other text <ins>added</ins> and of course some <del>changed</del><ins>replaced</ins>.</p>
<p>The word <span aria-invalid="spelling">smarple</span> is misspelled.</p>
<p>There is a grammar error in <span aria-invalid="grammar">these</span> paragraph.</p>
<p>The word <mark>fishtank</mark> is highlighted.</p>
<p>The word snotface<span aria-details="thread-3"><del>, however,</del></span> was considered inflammatory.</p>
<p>It's possible to <mark aria-details="thread-1 thread-4 thread-5">point</mark> to multiple comments.</p>
<p>It's possible to point to a group or region of comments ... <mark aria-details="comment-region">don't expect sensible comments here</mark>.</p>
<h1 id="p2">Priority 2</h1>
<p role="doc-subtitle">Once more unto the breach</p>
<div role="doc-toc">
<h3>Table of Contents -- usually would come earlier in document.</h3>
<p>Treat TOC as a landmark.</p>
<ul>
<li><a href="#p1">Priority 1 items</a></li>
<li><a href="#p2">Priority 2 items</a></li>
<li><a href="#p3">Priority 3 items</a></li>
</ul>
</div>
<div role="group" aria-label="Other users here now">
<p><span id="presence-1" </span></p>
</div>
<p><span aria-description="User nearby, Boaty McBoatface">Here is a sentence that is being edited by someone else.</span> Multiple authors can edit this document at the same time.</p>
<code style="display:block; white-space: pre; border: 2px solid black; margin: 5px;">// Here is some code with a conditional breakpoint inside the loop:
for (index = 0; index < 10; index ++) {
<span role="mark" class="breakpoint" aria-roledescription="breakpoint" aria-description="Condition: index == 2"> doSomething(index);</span>
}
</code>
<p>This content has a footnote<span role="doc-noteref" aria-details="footnote-1">1</span></p>
<p>Some random text with a <sub>subscript</sub> and <sup>superscript</sup>.</p>
<p>This is a paragraph that straddles the page break (and footnotes, footer and header). This paragraph actually</p>
<!-- We skip role=doc-backlink because, for consistency, we should always use aria-details.
Backlink would create a requirement to actually be a link because it's exposed via IA2 as a link.
By using aria-details on the source element we automatically get the reverse relation.
-->
<aside role="doc-footnote"><sup>1</sup> <span>Footnotes are useful and occasionally funny. Page break below this text.</span></aside>
<div role="doc-pagefooter">This is a running footer<span style="float:right">1</span></div>
<hr role="doc-pagebreak">
<div role="doc-pageheader">This is a running header<span style="float:right">Some author's name here</div>
<p>continues on the next page.</p>
<h1 id="p3">Priority 3 (this is page 2)</h1>
<!-- TBD: we need browser and AT implementations for running headers/footers: https://github.com/w3c/dpub-aam/issues/3 -->
<p>Some page 2 content.</p>
<p>Column text then a column break.<span role="separator" aria-roledescription="Column break" class="colbreak"> </span>Do we want to expose column breaks? Could be annoying to read.</p>
<!-- TBD: we need browser and AT implementations for running headers/footers: https://github.com/w3c/dpub-aam/issues/3 -->
<div role="doc-pagefooter">This is a running footer. In the future we'd like to have a built-in role for this rather than using a role descripton.</div>
</div>
<div id="comment-region" class="sidebar" role="region">
<h2>Comments</h2>
<div id="thread-1" role="comment">
Cats are liquid BTW<br>—Danny Ainge
<div role="comment">
No they aren't<br>—Magic Johnson
</div>
<div role="form">
<textarea cols="80" placeholder="Add reply..."></textarea>
<input type="submit">
</div>
</div>
<div id="thread-2" role="comment">
Replaced "oranges" with "clementines"<br>—Kevin McHale
</div>
<div id="thread-3" role="comment">
Deleted ", however,"<br>—Magic Johnson
</div>
<div id="thread-4" role="comment">
When you come to a fork in the road, take it.<br>—Yogi Berra
</div>
<div id="thread-5" role="comment">
The atoms or elementary particles themselves are not real; they form a world of potentialities or possibilities rather than one of things or facts.<br>—Werner Heisenberg
</div>
</div>
body { display: flex; }
[role="mark"] { background-color: pink; }
.editor, .sidebar { border: 2px solid green; padding: 4px; }
.sidebar { border-left: 0; }
.commented-text { background-color: hsl(60, 100%, 85%); }
[role="doc-noteref"] { vertical-align: super; font-size: smaller; }
[role="doc-pagefooter"] { margin-top: 1em; font-style: italic;}
[role="doc-pageheader"] { margin-bottom: 1em; font-style: italic;}
ins { color: green; }
del { color: red; }
[role="comment"] { margin: 1em; border: 1px solid gray; padding: 5px;}
[aria-invalid] { text-decoration: underline dotted; }
[aria-invalid="spelling"] { text-decoration-color: red; }
[aria-invalid="grammar"] { text-decoration-color: blue; }
.colbreak { width: 2em; display: inline-block; }
.breakpoint { background-color: red; color: white; font-weight: bold;}
Also see: Tab Triggers