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 URL's 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 it's URL and the proper URL extention.
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 class="toggles">
<button type="button" id="logical" aria-pressed="false" onclick="toggle(this.id);flipLogical();">
Logical
</button>
</div>
<h1>Block Quote Examples</h1>
<p>
Used in the blog post <cite><a href="https://adrianroselli.com/2019/11/css-logical-properties.html">CSS Logical Properties</a></cite>.
</p>
<h2>English</h2>
<blockquote class="typical">
<dl>
<dt>Bard</dt>
<dd><q>You two go downstairs and we’ll check up here.</q></dd>
<dt>(new) Cleric</dt>
<dd><q>Never split the party.</q></dd>
<dt>Bard</dt>
<dd><q>ALWAYS SPLIT THE PARTY! We can get more done.</q></dd>
</dl>
<p>
[ a statue starts shouting at the party ]
</p>
<dl>
<dt>Bard</dt>
<dd><q>Or we can all go downstairs.</q></dd>
</dl>
<footer>
<cite>Adrian Roselli (@aardrian) <a href="https://twitter.com/aardrian/status/1167223782588723200">August 29, 2019</a></cite>
</footer>
</blockquote>
<h2>Urdu</h2>
<p>
All I did was feed the text strings into Google Translate, add a <code>dir</code> and <code>lang</code>, and walk away.
</p>
<blockquote class="typical" dir="rtl" lang="ur">
<dl>
<dt>بارڈ</dt>
<dd><q>آپ دونوں نیچے چلے جائیں اور ہم یہاں چیک اپ کریں گے۔</q></dd>
<dt>(نئی) مولوی</dt>
<dd><q>کبھی پارٹی کو تقسیم نہ کریں۔</q></dd>
<dt>بارڈ</dt>
<dd><q>ہمیشہ پارٹی کو الگ! ہم مزید کام کر سکتے ہیں۔</q></dd>
</dl>
<p>
[ پارٹی میں ایک مجسمہ چیخنے لگا۔ ]
</p>
<dl>
<dt>بارڈ</dt>
<dd><q>یا ہم سب نیچے کی طرف جا سکتے ہیں۔</q></dd>
</dl>
<footer>
<cite>Adrian Roselli (@aardrian) <a href="https://twitter.com/aardrian/status/1167223782588723200">29 اگست ، 2019۔</a></cite>
</footer>
</blockquote>
<h2>Japanese</h2>
<p>
All I did was feed the text strings into Google Translate, add a <code>writing-mode</code> and <code>lang</code>, and walk away.
</p>
<blockquote class="typical" style="writing-mode: vertical-lr" lang="jp">
<dl>
<dt>吟遊詩人</dt>
<dd><q>2階下に行くと、ここでチェックします。</q></dd>
<dt>(新着) クレリック</dt>
<dd><q>パーティーを分割しないでください。</q></dd>
<dt>吟遊詩人</dt>
<dd><q>常にパーティーを分割します! さらに多くのことができます。</q></dd>
</dl>
<p>
[パーティーで彫像が叫び始める]
</p>
<dl>
<dt>吟遊詩人</dt>
<dd><q>または、私たちはすべて階下に行くことができます。</q></dd>
</dl>
<footer>
<cite>Adrian Roselli (@aardrian) <a href="https://twitter.com/aardrian/status/1167223782588723200">2019年8月29日</a></cite>
</footer>
</blockquote>
<h2>Chinese</h2>
<p>
All I did was feed the text strings into Google Translate, add a <code>writing-mode</code> and <code>lang</code>, and walk away.
</p>
<blockquote class="typical" style="writing-mode: vertical-rl" lang="zh">
<dl>
<dt>诗人</dt>
<dd><q>你们两个下楼,我们将在这里查看。</q></dd>
<dt>(新) 牧师</dt>
<dd><q>永远不要分开派对。</q></dd>
<dt>诗人</dt>
<dd><q>总是分裂党! 我们可以做得更多。</q></dd>
</dl>
<p>
[ 一个雕像开始在聚会上大喊大叫 ]
</p>
<dl>
<dt>诗人</dt>
<dd><q>或者我们都可以下楼了。</q></dd>
</dl>
<footer>
<cite>Adrian Roselli (@aardrian) <a href="https://twitter.com/aardrian/status/1167223782588723200">2019年8月29日</a></cite>
</footer>
</blockquote>
<p>
Used in the blog post <cite><a href="https://adrianroselli.com/">CSS Logical Properties</a></cite>.
</p>
body {
background-color: #fff;
color: #333;
margin: 5em 2em 5em 2em;
font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto,
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
line-height: 1.5;
/* line-height: 1.5; */
/* letter-spacing: 0.12em; */
/* word-spacing: 0.16em; */
/* font-size: 200%; */
}
code {
font-family: "Lucida Console", monospace;
color: #060;
}
blockquote {
/* very much breaking the rules here, */
/* so this will not work at all */
/* https://drafts.csswg.org/css-logical/#logical-shorthand-keyword */
background-image: logical radial-gradient(circle at block-start inline-start, #ff0 0, #fff 50%);
}
blockquote dt {
font-weight: bold;
}
blockquote p {
font-style: italic;
text-align: center;
}
blockquote dt::after {
content: ":";
}
blockquote cite::before {
content: "— ";
}
/* Styles we use today */
blockquote.typical {
max-width: 27em;
margin: 2em auto;
border-top: .2em solid #ccc;
border-left: .2em solid #ccc;
border-top-left-radius: 2em;
padding-top: .5em;
}
blockquote.typical > *:not(footer) {
margin: .5em 1em;
}
blockquote.typical footer {
text-align: right;
margin-top: 1.5em;
border-top: .05em solid #ccc;
padding-top: 1em;
padding-right: 1em;
}
blockquote.typical p {
margin: 1em auto;
}
blockquote.typical dt {
margin-top: .5em;
}
blockquote.typical dd {
margin-left: 1em;
}
/* New logical styles */
blockquote.logical {
max-inline-size: 27em;
margin-block: 2em;
margin-inline: auto;
border-block-start: .2em solid #ccc;
border-inline-start: .2em solid #ccc;
border-start-start-radius: 2em;
padding-block-start: .5em;
}
blockquote.logical > *:not(footer) {
margin-block: .5em;
margin-inline: 1em;
}
blockquote.logical footer {
text-align: end;
margin-block-start: 1.5em;
border-block-start: .05em solid #ccc;
padding-block-start: 1em;
padding-inline-end: 1em;
}
blockquote.logical p {
margin-block: 1em;
margin-inline: auto;
}
blockquote.logical dt {
margin-block-start: .5em;
}
blockquote.logical dd {
margin-inline-start: 1em;
}
/* Toggle */
/* https://adrianroselli.com/2019/08/under-engineered-toggles-too.html */
.toggles {
margin: 0;
padding: .5em 2em;
border-bottom: .1em solid #ccc;
position: fixed;
top: 0;
left: 0;
right: 0;
background-color: #fff;
}
.toggles [aria-pressed] {
display: block;
box-sizing: border-box;
border: none;
color: inherit;
background: none;
font: inherit;
line-height: inherit;
text-align: left;
padding: .4em 0 .4em 4em;
position: relative;
}
.toggles [aria-pressed][disabled],
.toggles [aria-pressed][disabled]:hover {
color: #999;
}
.toggles [aria-pressed]:focus,
.toggles [aria-pressed]:hover {
color: #00f;
outline: none;
}
.toggles [aria-pressed]:focus::before,
.toggles [aria-pressed]:hover::before {
box-shadow: 0 0 0.5em #333;
}
.toggles [aria-pressed]:focus::after,
.toggles [aria-pressed]:hover::after {
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='50' cy='50' r='50' fill='rgba(0,0,0,.25)'/%3E%3C/svg%3E");
background-size: 30%;
background-repeat: no-repeat;
background-position: center center;
}
.toggles [aria-pressed]::before,
.toggles [aria-pressed]::after {
content: "";
position: absolute;
height: 1.5em;
transition: all 0.25s ease;
}
.toggles [aria-pressed]::before {
left: 0;
top: 0.2em;
width: 3em;
border: 0.2em solid #767676;
background: #767676;
border-radius: 1.1em;
}
.toggles [aria-pressed]::after {
left: 0;
top: 0.25em;
background-color: #fff;
background-position: center center;
border-radius: 50%;
width: 1.5em;
border: 0.15em solid #767676;
}
.toggles [aria-pressed=true]::after {
left: 1.6em;
border-color: #36a829;
color: #36a829;
}
.toggles [aria-pressed=true]::before {
background-color: #36a829;
border-color: #36a829;
}
.toggles [aria-pressed][disabled]::before {
background-color: transparent;
border-color: #ddd;
}
.toggles [aria-pressed][disabled]::after {
border-color: #ddd;
}
.toggles [aria-pressed][disabled]:hover {
color: #999; /* case for CSS custom property if not supporting IE/Edge */
}
.toggles [aria-pressed][disabled]:hover::before {
box-shadow: none;
}
.toggles [aria-pressed][disabled]:hover::after {
background-image: none;
}
/* Put toggles on the right like the iOS the kids like */
.toggles.flip [aria-pressed]::before,
.toggles.flip [aria-pressed]::after {
left: auto;
right: 0;
}
.toggles.flip [aria-pressed]::after {
left: auto;
right: 1.6em;
}
.toggles.flip [aria-pressed=true]::after {
right: 0;
}
.toggles.flip [aria-pressed] {
padding-left: 0;
padding-right: 4em;
}
/* Windows High Contrast Mode Support */
@media screen and (-ms-high-contrast: active) {
.toggles [aria-pressed]:focus::before,
.toggles [aria-pressed]:hover::before {
outline: 1px dotted windowText;
outline-offset: 0.25em;
}
.toggles [aria-pressed]::after {
background-color: windowText;
}
.toggles [aria-pressed][disabled]::after {
background-color: transparent;
}
}
/* Reduced motion */
@media screen and (prefers-reduced-motion: reduce) {
.toggles [aria-pressed]::before,
.toggles [aria-pressed]::after {
transition: none;
}
}
/* Dark mode */
@media screen and (prefers-color-scheme: dark) {
.toggles {
color: #fff;
background-color: #101010;
}
fieldset.toggles {
border: 0.1em solid rgba(255, 255, 255, 0.15);
}
.toggles [aria-pressed]:focus,
.toggles [aria-pressed]:hover {
color: #99f;
}
.toggles [aria-pressed]::before {
border-color: #808080;
background: #808080;
}
.toggles [aria-pressed]::after {
background-color: #101010;
}
.toggles [aria-pressed]:focus::after,
.toggles [aria-pressed]:hover::after {
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='50' cy='50' r='50' fill='rgba(255,255,255,.25)'/%3E%3C/svg%3E");
}
.toggles [aria-pressed][disabled]::before,
.toggles [aria-pressed][disabled]::after {
border-color: #555;
}
}
/* RTL */
/* https://twitter.com/dror3go/status/1102946375396982784 */
*[dir="rtl"] .toggles [aria-pressed] {
padding-left: 0;
padding-right: 4em;
}
*[dir="rtl"] .toggles [aria-pressed]::before,
*[dir="rtl"] .toggles [aria-pressed]::after {
left: auto;
right: 0;
}
*[dir="rtl"] .toggles [aria-pressed]::after {
right: 0;
}
*[dir="rtl"] .toggles [aria-pressed=true]::after {
right: 1.6em;
}
/* Put toggles on the right like the iOS the kids like */
*[dir="rtl"] .toggles.flip [aria-pressed]::before,
*[dir="rtl"] .toggles.flip [aria-pressed]::after {
left: 0;
right: auto;
}
*[dir="rtl"] .toggles.flip [aria-pressed]::after {
right: auto;
left: 1.6em;
}
*[dir="rtl"] .toggles.flip [aria-pressed=true]::after {
left: 0;
}
*[dir="rtl"] .toggles.flip [aria-pressed] {
padding-right: 0;
padding-left: 4em;
}
function toggle(btnID) {
var theButton = document.getElementById(btnID);
if (theButton.getAttribute("aria-pressed") == "false") {
theButton.setAttribute("aria-pressed", "true");
} else {
theButton.setAttribute("aria-pressed", "false");
}
}
function flipLogical() {
var theQuote = document.getElementsByTagName("blockquote");
for (var i = 0; i < theQuote.length; i++) {
if (theQuote[i].getAttribute("class") == "typical") {
theQuote[i].setAttribute("class", "logical");
} else {
theQuote[i].setAttribute("class", "typical");
}
}
}
Also see: Tab Triggers