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 id="top" class="page" role="document">
<header role="banner">
<div class="open-props">
<svg class="op-icon" viewBox="0 0 200 200">
<line class="op-icon-p" x1="66" x2="66" y1="100" y2="175" stroke="var(--indigo-7)" stroke-width="25"/>
<circle class="op-icon-p" cx="100" cy="100" r="35" fill="transparent" stroke="var(--indigo-7)" stroke-width="25"/>
<circle class="op-icon-o" cx="100" cy="100" r="85" fill="transparent" stroke="var(--indigo-5)" stroke-width="25"/>
</svg>
<h1>Open Props</h1>
</div>
<p>A <a href="https://stackoverflow.com/questions/6887336/what-is-the-difference-between-normalize-css-and-reset-css#:~:text=51-,Normalize.,over%20the%20styling%20of%20everything.">normalize</a> using Open Props! Minimal styles for all HTML elements. Plus, it's adaptive to light and dark. The props are made available for you to continue building <a href="https://codepen.io/argyleink/pen/jOLaBgG">components</a> too.</p>
<div>
<h4>Included adaptive props</h4>
<h3>4 Surface Colors</h3>
<p>Great for cards, buttons, borders, sidenavs, wells, etc. When you want to change the perception of layering and grouping.</p>
<div class="surface-samples">
<div class="surface1 rad-shadow">var(--surface-1)</div>
<div class="surface2 rad-shadow">var(--surface-2)</div>
<div class="surface3 rad-shadow">var(--surface-3)</div>
<div class="surface4 rad-shadow">var(--surface-4)</div>
</div>
</div>
<div class="text-samples">
<h3>2 Text Colors, 2 link colors</h3>
<h5 class="text1">
<span class="swatch link rad-shadow"></span>
var(--link)
</h5>
<h5 class="text1">
<span class="swatch link-visited rad-shadow"></span>
var(--link-visited)
</h5>
<h5 class="text1">
<span class="swatch text1 rad-shadow"></span>
var(--text-1)
</h5>
<h5 class="text2">
<span class="swatch text2 rad-shadow"></span>
var(--text-2)
</h5>
<p>Using these props results in colors that adapt to the users system theme preference automatically.</p>
<p>The brand color is used sparingly, find it used in the HTML elements below! The link color is useful for buttons and other custom components you want to have consistent interactive text for.</p>
</div>
<hr>
<h2>Normalized HTML5 Elemenets</h2>
<p>Based on <a href="https://cbracco.github.io/html5-test-page">this html5 test page</a>.</p>
</header>
<nav role="navigation">
<ul>
<li>
<a href="#text">Text</a>
<ul>
<li><a href="#text__headings">Headings</a></li>
<li><a href="#text__paragraphs">Paragraphs</a></li>
<li><a href="#text__blockquotes">Blockquotes</a></li>
<li><a href="#text__lists">Lists</a></li>
<li><a href="#text__hr">Horizontal rules</a></li>
<li><a href="#text__tables">Tabular data</a></li>
<li><a href="#text__code">Code</a></li>
<li><a href="#text__inline">Inline elements</a></li>
<li><a href="#text__comments">HTML Comments</a></li>
</ul>
</li>
<li>
<a href="#embedded">Embedded content</a>
<ul>
<li><a href="#embedded__images">Images</a></li>
<li><a href="#embedded__audio">Audio</a></li>
<li><a href="#embedded__video">Video</a></li>
<li><a href="#embedded__canvas">Canvas</a></li>
<li><a href="#embedded__meter">Meter</a></li>
<li><a href="#embedded__progress">Progress</a></li>
<li><a href="#embedded__svg">Inline SVG</a></li>
<li><a href="#embedded__iframe">IFrames</a></li>
</ul>
</li>
<li>
<a href="#forms">Form elements</a>
<ul>
<li><a href="#forms__input">Input fields</a></li>
<li><a href="#forms__select">Select menus</a></li>
<li><a href="#forms__checkbox">Checkboxes</a></li>
<li><a href="#forms__radio">Radio buttons</a></li>
<li><a href="#forms__textareas">Textareas</a></li>
<li><a href="#forms__html5">HTML5 inputs</a></li>
<li><a href="#forms__action">Action buttons</a></li>
</ul>
</li>
</ul>
</nav>
<main role="main">
<section id="text">
<article id="text__headings">
<div>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
</div>
</article>
<article id="text__paragraphs">
<header><h1>Paragraphs</h1></header>
<div>
<p>A paragraph (from the Greek paragraphos, “to write beside” or “written beside”) is a self-contained unit of a discourse in writing dealing with a particular point or idea. A paragraph consists of one or more sentences. Though not required by the syntax of any language, paragraphs are usually an expected part of formal writing, used to organize longer prose.</p>
</div>
</article>
<article id="text__blockquotes">
<header><h1>Blockquotes</h1></header>
<div>
<blockquote>
<p>A block quotation (also known as a long quotation or extract) is a quotation in a written document, that is set off from the main text as a paragraph, or block of text.</p>
<p>It is typically distinguished visually using indentation and a different typeface or smaller size quotation. It may or may not include a citation, usually placed at the bottom.</p>
<cite><a href="#!">Said no one, ever.</a></cite>
</blockquote>
</div>
</article>
<article id="text__lists">
<header><h1>Lists</h1></header>
<div>
<h3>Definition list</h3>
<dl>
<dt>Definition List Title</dt>
<dd>This is a definition list division.</dd>
<dt>Definition List Title 2</dt>
<dd>This is a definition list division item with a lot more to say.</dd>
</dl>
<h3>Ordered List</h3>
<ol>
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ol>
<h3>Unordered List</h3>
<ul>
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ul>
<h3>Details</h3>
<details>
<summary>Details and summary element</summary>
<p>Example paragraph text.</p>
</details>
</div>
</article>
<article id="text__hr">
<header><h1>Horizontal rules</h1></header>
<div>
<hr>
</div>
</article>
<article id="text__tables">
<header><h1>Tabular data</h1></header>
<table>
<caption>Table Caption</caption>
<thead>
<tr>
<th>Table Heading 1</th>
<th>Table Heading 2</th>
<th>Table Heading 3</th>
<th>Table Heading 4</th>
<th>Table Heading 5</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Table Footer 1</th>
<th>Table Footer 2</th>
<th>Table Footer 3</th>
<th>Table Footer 4</th>
<th>Table Footer 5</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Table Cell 1</td>
<td>Table Cell 2</td>
<td>Table Cell 3</td>
<td>Table Cell 4</td>
<td>Table Cell 5</td>
</tr>
<tr>
<td>Table Cell 1</td>
<td>Table Cell 2</td>
<td>Table Cell 3</td>
<td>Table Cell 4</td>
<td>Table Cell 5</td>
</tr>
<tr>
<td>Table Cell 1</td>
<td>Table Cell 2</td>
<td>Table Cell 3</td>
<td>Table Cell 4</td>
<td>Table Cell 5</td>
</tr>
<tr>
<td>Table Cell 1</td>
<td>Table Cell 2</td>
<td>Table Cell 3</td>
<td>Table Cell 4</td>
<td>Table Cell 5</td>
</tr>
</tbody>
</table>
</article>
<article id="text__code">
<header><h1>Code</h1></header>
<div>
<p><strong>Keyboard input:</strong> <kbd>Cmd</kbd></p>
<p><strong>Inline code:</strong> <code><div>code</div></code></p>
<p><strong>Sample output:</strong> <samp>This is sample output from a computer program.</samp></p>
<h2>Pre-formatted text</h2>
<pre>P R E F O R M A T T E D T E X T
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ </pre>
</div>
</article>
<article id="text__inline">
<header><h1>Inline elements</h1></header>
<div>
<p><a href="#!">This is a text link</a>.</p>
<p><strong>Strong is used to indicate strong importance.</strong></p>
<p><em>This text has added emphasis.</em></p>
<p>The <b>b element</b> is stylistically different text from normal text, without any special importance.</p>
<p>The <i>i element</i> is text that is offset from the normal text.</p>
<p>The <u>u element</u> is text with an unarticulated, though explicitly rendered, non-textual annotation.</p>
<p><del>This text is deleted</del> and <ins>This text is inserted</ins>.</p>
<p><s>This text has a strikethrough</s>.</p>
<p>Superscript<sup>®</sup>.</p>
<p>Subscript for things like H<sub>2</sub>O.</p>
<p><small>This small text is small for for fine print, etc.</small></p>
<p>Abbreviation: <abbr title="HyperText Markup Language">HTML</abbr></p>
<p><q cite="./index_files/q">This text is a short inline quotation.</q></p>
<p><cite>This is a citation.</cite></p>
<p>The <dfn>dfn element</dfn> indicates a definition.</p>
<p>The <mark>mark element</mark> indicates a highlight.</p>
<p>The <var>variable element</var>, such as <var>x</var> = <var>y</var>.</p>
<p>The time element: <time datetime="2013-04-06T12:32+00:00">2 weeks ago</time></p>
</div>
</article>
<article id="text__comments">
<header><h1>HTML Comments</h1></header>
<div>
<p>There is comment here: <!--This comment should not be displayed--></p>
<p>There is a comment spanning multiple tags and lines below here.</p>
<!--<p><a href="#!">This is a text link. But it should not be displayed in a comment</a>.</p>
<p><strong>Strong is used to indicate strong importance. But, it should not be displayed in a comment</strong></p>
<p><em>This text has added emphasis. But, it should not be displayed in a comment</em></p>-->
</div>
</article>
</section>
<section id="embedded">
<header><h1>Embedded content</h1></header>
<article id="embedded__images">
<header><h2>Images</h2></header>
<div class="spaced">
<h5>No <code><figure></code> element</h5>
<p><img src="https://doodleipsum.com/420/outline?bg=7463D9&i=5493adbcd8a47597df8e1fc4b1b87733" alt="Image alt text"></p>
<h5>Wrapped in a <code><figure></code> element, no <code><figcaption></code></h5>
<figure><img src="https://doodleipsum.com/420/outline?bg=7463D9&i=5493adbcd8a47597df8e1fc4b1b87733" alt="Image alt text"></figure>
<h5>Wrapped in a <code><figure></code> element, with a <code><figcaption></code></h5>
<figure>
<img src="https://doodleipsum.com/420/outline?bg=7463D9&i=5493adbcd8a47597df8e1fc4b1b87733" alt="Image alt text">
<figcaption>Here is a caption for this image.</figcaption>
</figure>
</div>
</article>
<article id="embedded__audio">
<header><h2>Audio</h2></header>
<div><audio controls="">audio</audio></div>
</article>
<article id="embedded__video">
<header><h2>Video</h2></header>
<div><video controls="">video</video></div>
</article>
<article id="embedded__canvas">
<header><h2>Canvas</h2></header>
<div><canvas>canvas</canvas></div>
</article>
<article id="embedded__meter">
<header><h2>Meter</h2></header>
<div><meter value="2" min="0" max="10">2 out of 10</meter></div>
</article>
<article id="embedded__progress">
<header><h2>Progress</h2></header>
<div>
<progress indeterminate>progress</progress>
<progress value=".5">progress</progress>
</div>
</article>
<article id="embedded__svg">
<header><h2>Inline SVG</h2></header>
<div><svg width="100px" height="100px"><circle cx="100" cy="100" r="100" fill="#1fa3ec"></circle></svg></div>
</article>
<article id="embedded__iframe">
<header><h2>IFrame</h2></header>
<div><iframe src="./index_files/index.html" height="300"></iframe></div>
</article>
</section>
<section id="forms">
<header><h1>Form elements</h1></header>
<form>
<fieldset id="forms__input">
<legend>Input fields</legend>
<p>
<label for="input__text">Text Input</label>
<input id="input__text" type="text" placeholder="Text Input">
</p>
<p>
<label for="input__password">Password</label>
<input id="input__password" type="password" placeholder="Type your Password">
</p>
<p>
<label for="input__webaddress">Web Address</label>
<input id="input__webaddress" type="url" placeholder="http://yoursite.com">
</p>
<p>
<label for="input__emailaddress">Email Address</label>
<input id="input__emailaddress" type="email" placeholder="name@email.com">
</p>
<p>
<label for="input__phone">Phone Number</label>
<input id="input__phone" type="tel" placeholder="(999) 999-9999">
</p>
<p>
<label for="input__search">Search</label>
<input id="input__search" type="search" placeholder="Enter Search Term">
</p>
<p>
<label for="input__text2">Number Input</label>
<input id="input__text2" type="number" placeholder="Enter a Number">
</p>
<p>
<label for="input__text3" class="error">Error</label>
<input id="input__text3" class="is-error" type="text" placeholder="Text Input">
</p>
<p>
<label for="input__text4" class="valid">Valid</label>
<input id="input__text4" class="is-valid" type="text" placeholder="Text Input">
</p>
</fieldset>
<fieldset id="forms__select">
<legend>Select menus</legend>
<p>
<label for="select">Select</label>
<select id="select">
<optgroup label="Option Group">
<option>Option One</option>
<option>Option Two</option>
<option>Option Three</option>
</optgroup>
</select>
</p>
</fieldset>
<fieldset id="forms__checkbox">
<legend>Checkboxes</legend>
<ul class="list list--bare">
<li><label for="checkbox1"><input id="checkbox1" name="checkbox" type="checkbox" checked="checked"> Choice A</label></li>
<li><label for="checkbox2"><input id="checkbox2" name="checkbox" type="checkbox"> Choice B</label></li>
<li><label for="checkbox3"><input id="checkbox3" name="checkbox" type="checkbox"> Choice C</label></li>
</ul>
</fieldset>
<fieldset id="forms__radio">
<legend>Radio buttons</legend>
<ul class="list list--bare">
<li><label for="radio1"><input id="radio1" name="radio" type="radio" class="radio" checked="checked"> Option 1</label></li>
<li><label for="radio2"><input id="radio2" name="radio" type="radio" class="radio"> Option 2</label></li>
<li><label for="radio3"><input id="radio3" name="radio" type="radio" class="radio"> Option 3</label></li>
</ul>
</fieldset>
<fieldset id="forms__textareas">
<legend>Textareas</legend>
<p>
<label for="textarea">Textarea</label>
<textarea id="textarea" rows="8" cols="48" placeholder="Enter your message here"></textarea>
</p>
</fieldset>
<fieldset id="forms__html5">
<legend>HTML5 inputs</legend>
<p>
<label for="ic">Color input</label>
<input type="color" id="ic" value="#000000">
</p>
<p>File input <input type="file"></p>
<p>
<label for="in">Number input</label>
<input type="number" id="in" min="0" max="10" value="5">
</p>
<p>
<label for="ir">Range input</label>
<input type="range" id="ir" value="10">
</p>
<p>
<label for="ir">Progress input</label>
<progress></progress>
<progress value=".5" />50%</progress>
</p>
<p>
<label for="idd">Date input</label>
<input type="date" id="idd" value="1970-01-01">
</p>
<p>
<label for="idm">Month input</label>
<input type="month" id="idm" value="1970-01">
</p>
<p>
<label for="idw">Week input</label>
<input type="week" id="idw" value="1970-W01">
</p>
<p>
<label for="idt">Datetime input</label>
<input type="datetime" id="idt" value="1970-01-01T00:00:00Z">
</p>
<p>
<label for="idtl">Datetime-local input</label>
<input type="datetime-local" id="idtl" value="1970-01-01T00:00">
</p>
</fieldset>
<fieldset id="forms__action">
<legend>Action buttons</legend>
<p class="buttons-list">
<input type="submit" value="<input type=submit>">
<input type="button" value="<input type=button>">
<input type="reset" value="<input type=reset>">
<input type="submit" value="<input disabled>" disabled="">
</p>
<br>
<p class="buttons-list">
<button type="submit"><button type=submit></button>
<button type="button"><button type=button></button>
<button type="reset"><button type=reset></button>
<button type="button" disabled=""><button disabled></button>
</p>
</fieldset>
</form>
</section>
</main>
</div>
@import "https://unpkg.com/open-props";
@import "https://unpkg.com/open-props/normalize.min.css";
@import "https://unpkg.com/open-props/buttons.min.css";
/* demo purpose only */
body {
display: grid;
place-content: center;
padding: var(--size-7);
gap: var(--size-7);
}
article, section, form, fieldset, header, .page, .spaced, #text__lists > div, #text__code > div, #text__inline > div {
display: grid;
gap: var(--size-4);
}
nav > ul {
display: flex;
list-style-type: none;
padding-inline-start: 0;
gap: var(--size-5);
}
.open-props {
display: flex;
align-items: center;
gap: var(--size-3);
}
.surface-samples {
display: grid;
--size: var(--size-content-1);
grid-template-columns: var(--size) var(--size);
grid-auto-rows: var(--size);
gap: var(--size-5);
margin-block-start: var(--size-6);
}
@media (width <= 480px) {
.surface-samples {
--size: 40vw;
}
}
.surface-samples > * {
border-radius: var(--radius-3);
display: grid;
place-content: center;
font-size: var(--font-size-3);
font-weight: var(--font-weight-2);
box-shadow: var(--shadow-6);
}
.surface1 {
background-color: var(--surface-1);
color: var(--text-2);
}
.surface2 {
background-color: var(--surface-2);
color: var(--text-2);
}
.surface3 {
background-color: var(--surface-3);
color: var(--text-1);
}
.surface4 {
background-color: var(--surface-4);
color: var(--text-1);
}
.text-samples {
display: grid;
gap: var(--size-3);
}
.text-samples > h5 {
display: inline-flex;
align-items: center;
gap: var(--size-3);
}
.text1 {
color: var(--text-1);
}
p.text1 {
font-weight: var(--font-weight-2);
}
.text2 {
color: var(--text-2);
}
.brand {
color: var(--brand);
background-color: var(--brand);
}
.link {
color: var(--link);
background-color: var(--link);
}
.link-visited {
color: var(--link-visited);
background-color: var(--link-visited);
}
.swatch {
display: inline-block;
flex-shrink: 0;
inline-size: var(--size-8);
block-size: var(--size-8);
border-radius: var(--radius-round);
box-shadow: var(--shadow-4);
}
.swatch.text1 { background-color: var(--text-1); }
.swatch.text2 { background-color: var(--text-2); }
.buttons-list {
display: flex;
align-items: flex-start;
gap: var(--size-3);
flex-wrap: wrap;
}
#forms__html5 > p {
display: flex;
align-items: center;
gap: var(--size-3);
}
Also see: Tab Triggers