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.
<h1>Disability:IN Agenda Bookmarklet</h1>
<p>
I had some issues using the <a href="https://disabilityin.org/2024conference/2024-conference-agenda/" target="_top">Disability:IN 2024 Conference Agenda</a> so I made a bookmarklet:
</p>
<p>
š <strong><a href="javascript:(function(){var a=document.createElement('style'),b;document.head.appendChild(a);b=a.sheet;b.insertRule('h3 > a{display:none !important}',0);b.insertRule('@keyframes Target{from{outline-offset:-.25em;outline-color:#00f;outline-width:0.1em}to{outline-offset:2em;outline-color:transparent;outline-width:1em}}',0);b.insertRule(':target{outline-width:0.2em;outline-style:solid;outline-color:#00f}',0);b.insertRule('@media screen and (prefers-reduced-motion: no-preference){:target{outline-width:0;animation:Target 1s ease-out 3}}',0);b.insertRule('.fusion-is-sticky .fusion-header-v1 .fusion-header{position:unset}',0);b.insertRule('div[id^=panel].fusion-panel.panel-default::before{content:\'#\' attr(id);display:inline-block;margin-top:2em}',0);b.insertRule('a[aria-expanded]{line-height:1.25 !important}',0);const h3=document.querySelectorAll('.sticky>h3');h3.forEach(h=>{const h2=document.createElement('h2');h2.innerHTML=h.innerText;h.replaceWith(h2)});})()">Fix Disability:IN Agenda</a></strong>
</p>
<p>
I made this into a post on my site so I could embed videos and images showing the effect of the changes: <a href="https://adrianroselli.com/2024/06/disabilityin-2024-agenda-bookmarklet.html" target="_top"><cite>Disability:IN 2024 Agenda Bookmarklet</cite></a>
</p>
<h2>Fixes</h2>
<ol>
<li>Removes empty trigger link before each session, which cuts tab-stops in half and undoes a 4.1.2 violation for a disclosure trigger with no accName.</li>
<li>Makes the sticky header unsticky, reducing some hassle for my zoomed viewport with panels open.</li>
<li>Loosens up the leading a tiny bit in the session names / headings and adds a bit of space above each.</li>
<li>Because each session has an <code>id</code> and I want to link to specific sessions, I added a <code>:target</code> style to make it more obvious which one I linked. The page uses some scroll-linked animations, so this will be hit-and/or-miss.</li>
<li>For those who also link to session anchors, I add the <code>id</code> value above each session. Sadly, it is not selectable since it uses CSS generated content. I opted not to add links since this page is a tab-stop forest.</li>
<li>Converts all the date headings from <code><h3></code> to <code><h2></code> for a more reasonable heading structure (and easier navigation for SR users).</li>
</ol>
<p>
The disclosure triggers as links bother me, but probably not worth converting to buttons. While that would make it more appealing to then add anchor links, keyboard users would be back up to too many tab-stops even if screen reader users could navigate by buttons alone.
</p>
<h2>Code</h2>
<p>
Script to change date <code><h3></code>s to <code><h2></code>:
</p>
<pre><code>const h3 = document.querySelectorAll(".sticky>h3");
h3.forEach(h => {
const h2 = document.createElement("h2");
h2.innerHTML = h.innerText;
h.replaceWith(h2)
})</code></pre>
<p>
These are the style changes it makes:
</p>
<pre><code>/* Removes unnamed tab-stop / redundant disclosure trigger */
h3 > a {
display: none !important;
}
/* Style an anchor when it has been navigated */
@keyframes Target {
from { outline-offset: -.25em; outline-color: #00f; outline-width: .1em; }
to { outline-offset: 2em; outline-color: transparent; outline-width: 1em; }
}
:target {
outline-width: .2em;
outline-style: solid;
outline-color: #00f;
}
@media screen and (prefers-reduced-motion: no-preference) {
:target {
outline-width: 0;
animation: Target 1s ease-out 3;
}
}
/* Get the sticky header out of the way */
.fusion-is-sticky .fusion-header-v1 .fusion-header {
position: unset;
}
/* Make an anchor option visible, but sadly not copyable */
div[id^=panel].fusion-panel.panel-default::before {
content: '#' attr(id);
display: inline-block;
margin-top: 2em;
}
/* Loosen up the leading for easier reading */
a[aria-expanded] {
line-height: 1.25 !important;;
}</code></pre>
html {
color-scheme: light dark;
/* Uncomment to center in the viewport */
/* block-size: 100svb; */
}
@supports (font: -apple-system-body) and (not (-webkit-touch-callout: default)) {
:root {
font-size: 100%;
}
}
body {
font: -apple-system-body;
font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto,
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
line-height: 1.4;
/* Uncomment to center in the viewport */
/* min-block-size: 100svb;
margin: 0;
display: grid;
place-content: center; */
/* line-height: 1.5; */
/* letter-spacing: 0.12em; */
/* word-spacing: 0.16em; */
}
code,
pre,
tt,
kbd {
font-family: "Consolas", "Andale Mono", "Lucida Sans Typewriter",
"Roboto Mono", "SF Mono", "Courier New", Courier, monospace;
font-weight: normal;
font-variant-ligatures: none;
opacity: 0.8;
}
pre {
max-width: 100%;
overflow: auto;
border: .1em solid;
padding: .1em .5em
}
Also see: Tab Triggers