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.
<h1>Tables with sticky rows and cols</h1>
<h2>Table with a sticky row</h2>
<div style="height: 480px; ">
<div class="scrollable sticky-rows">
<table lang="en">
<thead class="sticky row">
<tr><th>Name<th>Description<th>Legacy code exception field value (if any)
<tbody>
<tr>
<td>"IndexSizeError"
<td>The index is not in the allowed range.
<td><code>INDEX_SIZE_ERR (1)
<tr>
<td>"HierarchyRequestError"
<td>The operation would yield an incorrect node tree.
<td><code>HIERARCHY_REQUEST_ERR (3)
<tr>
<td>"WrongDocumentError"
<td>The object is in the wrong document.
<td><code>WRONG_DOCUMENT_ERR (4)
<tr>
<td>"InvalidCharacterError"
<td>The string contains invalid characters.
<td><code>INVALID_CHARACTER_ERR (5)
<tr>
<td>"NoModificationAllowedError"
<td>The object can not be modified.
<td><code>NO_MODIFICATION_ALLOWED_ERR (7)
<tr>
<td>"NotFoundError"
<td>The object can not be found here.
<td><code>NOT_FOUND_ERR (8)
<tr>
<td>"NotSupportedError"
<td>The operation is not supported.
<td><code>NOT_SUPPORTED_ERR (9)
<tr>
<td>"InvalidStateError"
<td>The object is in an invalid state.
<td><code>INVALID_STATE_ERR (11)
<tr>
<td>"SyntaxError"
<td>The string did not match the expected pattern.
<td><code>SYNTAX_ERR (12)
<tr>
<td>"InvalidModificationError"
<td>The object can not be modified in this way.
<td><code>INVALID_MODIFICATION_ERR (13)
<tr>
<td>"NamespaceError"
<td>The operation is not allowed by <cite>Namespaces in XML</cite>. [XMLNS]
<td><code>NAMESPACE_ERR (14)
<tr>
<td>"InvalidAccessError"
<td>The object does not support the operation or argument.
<td><code>INVALID_ACCESS_ERR (15)
<tr>
<!-- XHR -->
<td>"SecurityError"
<td>The operation is insecure.
<td><code>SECURITY_ERR (18)
<tr>
<!-- XHR -->
<td>"NetworkError"
<td>A network error occurred.
<td><code>NETWORK_ERR (19)
<tr>
<!-- XHR -->
<td>"AbortError"
<td>The operation was aborted.
<td><code>ABORT_ERR (20)
<tr>
<!-- Workers -->
<td>"URLMismatchError"
<td>The given URL does not match another URL.
<td><code>URL_MISMATCH_ERR (21)
<tr>
<!-- HTML -->
<td>"QuotaExceededError"
<td>The quota has been exceeded.
<td><code>QUOTA_EXCEEDED_ERR (22)
<tr>
<!-- XHR -->
<td>"TimeoutError"
<td>The operation timed out.
<td><code>TIMEOUT_ERR (23)
<tr>
<td>"InvalidNodeTypeError"
<td>The supplied node is incorrect or has an incorrect ancestor for this operation.
<td><code>INVALID_NODE_TYPE_ERR (24)
<tr>
<!-- HTML -->
<td>"DataCloneError"
<td>The object can not be cloned.
<td><code>DATA_CLONE_ERR (25)
<tr>
<td>"EncodingError"
<td>The encoding operation (either encoded or decoding) failed.
<td>—
</table>
</div>
</div>
<h2>Tabls with a sticky col</h2>
<div style="width: 640px;">
<div class="scrollable sticky-cols">
<table lang="en">
<thead>
<tr><th class="sticky col">Name<th>Description<th>Legacy code exception field value (if any)
<tbody>
<tr>
<td class="sticky col">"IndexSizeError"
<td>The index is not in the allowed range.
<td><code>INDEX_SIZE_ERR (1)
<tr>
<td class="sticky col">"HierarchyRequestError"
<td>The operation would yield an incorrect node tree.
<td><code>HIERARCHY_REQUEST_ERR (3)
<tr>
<td class="sticky col">"WrongDocumentError"
<td>The object is in the wrong document.
<td><code>WRONG_DOCUMENT_ERR (4)
<tr>
<td class="sticky col">"InvalidCharacterError"
<td>The string contains invalid characters.
<td><code>INVALID_CHARACTER_ERR (5)
<tr>
<td class="sticky col">"NoModificationAllowedError"
<td>The object can not be modified.
<td><code>NO_MODIFICATION_ALLOWED_ERR (7)
<tr>
<td class="sticky col">"NotFoundError"
<td>The object can not be found here.
<td><code>NOT_FOUND_ERR (8)
<tr>
<td class="sticky col">"NotSupportedError"
<td>The operation is not supported.
<td><code>NOT_SUPPORTED_ERR (9)
<tr>
<td class="sticky col">"InvalidStateError"
<td>The object is in an invalid state.
<td><code>INVALID_STATE_ERR (11)
<tr>
<td class="sticky col">"SyntaxError"
<td>The string did not match the expected pattern.
<td><code>SYNTAX_ERR (12)
<tr>
<td class="sticky col">"InvalidModificationError"
<td>The object can not be modified in this way.
<td><code>INVALID_MODIFICATION_ERR (13)
<tr>
<td class="sticky col">"NamespaceError"
<td>The operation is not allowed by <cite>Namespaces in XML</cite>. [XMLNS]
<td><code>NAMESPACE_ERR (14)
<tr>
<td class="sticky col">"InvalidAccessError"
<td>The object does not support the operation or argument.
<td><code>INVALID_ACCESS_ERR (15)
<tr>
<!-- XHR -->
<td class="sticky col">"SecurityError"
<td>The operation is insecure.
<td><code>SECURITY_ERR (18)
<tr>
<!-- XHR -->
<td class="sticky col">"NetworkError"
<td>A network error occurred.
<td><code>NETWORK_ERR (19)
<tr>
<!-- XHR -->
<td class="sticky col">"AbortError"
<td>The operation was aborted.
<td><code>ABORT_ERR (20)
<tr>
<!-- Workers -->
<td class="sticky col">"URLMismatchError"
<td>The given URL does not match another URL.
<td><code>URL_MISMATCH_ERR (21)
<tr>
<!-- HTML -->
<td class="sticky col">"QuotaExceededError"
<td>The quota has been exceeded.
<td><code>QUOTA_EXCEEDED_ERR (22)
<tr>
<!-- XHR -->
<td class="sticky col">"TimeoutError"
<td>The operation timed out.
<td><code>TIMEOUT_ERR (23)
<tr>
<td class="sticky col">"InvalidNodeTypeError"
<td>The supplied node is incorrect or has an incorrect ancestor for this operation.
<td><code>INVALID_NODE_TYPE_ERR (24)
<tr>
<!-- HTML -->
<td class="sticky col">"DataCloneError"
<td>The object can not be cloned.
<td><code>DATA_CLONE_ERR (25)
<tr>
<td class="sticky col">"EncodingError"
<td>The encoding operation (either encoded or decoding) failed.
<td>—
</table>
</div>
</div>
</div>
</div>
<h2>Table with sticky row and col</h2>
<div style="width: 640px; height: 480px;">
<div class="scrollable sticky-rows sticky-cols">
<table lang="en">
<thead class="sticky row">
<tr><th class="sticky col">Name<th>Description<th>Legacy code exception field value (if any)
<tbody>
<tr>
<td class="sticky col">"IndexSizeError"
<td>The index is not in the allowed range.
<td><code>INDEX_SIZE_ERR (1)
<tr>
<td class="sticky col">"HierarchyRequestError"
<td>The operation would yield an incorrect node tree.
<td><code>HIERARCHY_REQUEST_ERR (3)
<tr>
<td class="sticky col">"WrongDocumentError"
<td>The object is in the wrong document.
<td><code>WRONG_DOCUMENT_ERR (4)
<tr>
<td class="sticky col">"InvalidCharacterError"
<td>The string contains invalid characters.
<td><code>INVALID_CHARACTER_ERR (5)
<tr>
<td class="sticky col">"NoModificationAllowedError"
<td>The object can not be modified.
<td><code>NO_MODIFICATION_ALLOWED_ERR (7)
<tr>
<td class="sticky col">"NotFoundError"
<td>The object can not be found here.
<td><code>NOT_FOUND_ERR (8)
<tr>
<td class="sticky col">"NotSupportedError"
<td>The operation is not supported.
<td><code>NOT_SUPPORTED_ERR (9)
<tr>
<td class="sticky col">"InvalidStateError"
<td>The object is in an invalid state.
<td><code>INVALID_STATE_ERR (11)
<tr>
<td class="sticky col">"SyntaxError"
<td>The string did not match the expected pattern.
<td><code>SYNTAX_ERR (12)
<tr>
<td class="sticky col">"InvalidModificationError"
<td>The object can not be modified in this way.
<td><code>INVALID_MODIFICATION_ERR (13)
<tr>
<td class="sticky col">"NamespaceError"
<td>The operation is not allowed by <cite>Namespaces in XML</cite>. [XMLNS]
<td><code>NAMESPACE_ERR (14)
<tr>
<td class="sticky col">"InvalidAccessError"
<td>The object does not support the operation or argument.
<td><code>INVALID_ACCESS_ERR (15)
<tr>
<!-- XHR -->
<td class="sticky col">"SecurityError"
<td>The operation is insecure.
<td><code>SECURITY_ERR (18)
<tr>
<!-- XHR -->
<td class="sticky col">"NetworkError"
<td>A network error occurred.
<td><code>NETWORK_ERR (19)
<tr>
<!-- XHR -->
<td class="sticky col">"AbortError"
<td>The operation was aborted.
<td><code>ABORT_ERR (20)
<tr>
<!-- Workers -->
<td class="sticky col">"URLMismatchError"
<td>The given URL does not match another URL.
<td><code>URL_MISMATCH_ERR (21)
<tr>
<!-- HTML -->
<td class="sticky col">"QuotaExceededError"
<td>The quota has been exceeded.
<td><code>QUOTA_EXCEEDED_ERR (22)
<tr>
<!-- XHR -->
<td class="sticky col">"TimeoutError"
<td>The operation timed out.
<td><code>TIMEOUT_ERR (23)
<tr>
<td class="sticky col">"InvalidNodeTypeError"
<td>The supplied node is incorrect or has an incorrect ancestor for this operation.
<td><code>INVALID_NODE_TYPE_ERR (24)
<tr>
<!-- HTML -->
<td class="sticky col">"DataCloneError"
<td>The object can not be cloned.
<td><code>DATA_CLONE_ERR (25)
<tr>
<td class="sticky col">"EncodingError"
<td>The encoding operation (either encoded or decoding) failed.
<td>—
</table>
</div>
</div>
<address>The table data originates from <a href="http://www.w3.org/TR/2014/WD-dom-20140204/">W3C DOM4 (Last Call Working Draft 04 February 2014)</a> licensed by <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY</a>. Copyright © 2014 <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a>.</address>
.scrollable {
width:-moz-fit-content;
width:-ms-fit-content;
width:-webkit-fit-content;
width:fit-content;
}
.scrollable.sticky-rows {
overflow-y: scroll;
max-height: 100%;
}
.scrollable.sticky-cols {
overflow-x: scroll;
max-width: 100%;
}
.scrollable.sticky-cols > table {
width: -moz-max-content;
width: -ms-max-content;
width: -webkit-max-content;
width: max-content;
}
.scrollable .sticky {
position: sticky;
}
.scrollable .sticky.row {
top: 0;
z-index: 1;
}
.scrollable .sticky.col {
left: 0;
}
.scrollable {
border: thin solid silver;
}
.scrollable > table {
border-spacing: 0;
}
.scrollable td,
.scrollable th {
border-right: thin solid silver;
border-bottom: thin solid silver;
padding: 1em;
}
.scrollable td.sticky,
.scrollable th.sticky,
.scrollable .sticky td,
.scrollable .sticky th {
background:#ffa;
}
Also see: Tab Triggers