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>Water.css</h1>
<p>
Water.css is a just-add-css collection of styles to make simple websites
like this just a little bit nicer.
<a href='https://github.com/kognise/water.css'>Get it already!</a>
</p>
<p>
Now you can write your simple static site with nice semantic html, and
Water.css will manage the styling for you.
</p>
<a
href='https://www.producthunt.com/posts/water-css?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-water-css'
target='_blank'
><img
id='ph'
src='https://api.producthunt.com/widgets/embed-image/v1/top-post-badge.svg?post_id=150490&theme=dark&period=daily'
alt='Water.css - Make your tiny website just a little nicer | Product Hunt Embed'
width='250'
height='54'
/></a>
<h2>Goals</h2>
<ul>
<li>Responsive</li>
<li>Good code quality</li>
<li>Good browser support</li>
<li>Small size (< 2kb)</li>
<li>Beautiful</li>
<li>No classes</li>
</ul>
<h2>Is it responsive?</h2>
<p>
<strong>Heck yeah!</strong> It doesn't include any fancy styles so it's
easily mobile responsive. Just add the famous
<a href='https://www.w3schools.com/css/css_rwd_viewport.asp'
>responsive viewport tag</a
>
and you'll be good to go!
</p>
<p>
In fact, try resizing this page. Everything flows super nicely as you'll
see.
</p>
<button type='button' id='switch'>Switch theme</button>
<h2>Element demos</h2>
<p>
This is supposed to be a demo page so we need more elements!
</p>
<h3>Form elements</h3>
<form>
<fieldset>
<legend>Fieldset</legend>
<label for='email'>Email</label>
<input
type='email'
name='email'
id='email'
placeholder='john.doe@gmail.com'
/>
<label for='password'>Password</label>
<input
type='password'
name='password'
id='password'
placeholder='password'
/>
<p>
<input type='checkbox' name='remember' id='remember' checked />
<label for='remember'>Remember me</label>
</p>
<input type='submit' />
</fieldset>
<label for='id'>User id (read only)</label>
<input readonly name='id' id='id' value='04D6H89Z' />
<label for='disabled'>Random disabled input</label>
<input
disabled
name='disabled'
id='disabled'
placeholder='Because why not?'
/>
<label for='about'>About me</label>
<textarea
name='about'
id='about'
placeholder='I am a textarea...'
></textarea>
<label for='drink'>Select your favorite drink</label>
<select name='drinks' id='drink'>
<option value='mojito'>Mojito</option>
<option value='water'>Water</option>
<option value='lemon'>Lemon juice</option>
</select>
<label for='drinks'>Or select multiple favorite drinks</label>
<br/>
<small>Hold down the Ctrl (Windows) / Command (Mac) button to select multiple options. (P.S. this message is inside a <code><small></code> tag!</small>)
<select name='drink' id='drinks' multiple>
<option value='mojito'>Mojito</option>
<option value='water'>Water</option>
<option value='lemon'>Lemon juice</option>
</select>
<label>Choose a Doe:</label>
<div>
<input type='radio' id='john' name='doe' value='john' checked>
<label for='john'>John Doe</label>
</div>
<div>
<input type='radio' id='jane' name='doe' value='jane' checked>
<label for='jane'>Jane Doe</label>
</div>
<div>
<input type='radio' id='johnny' name='doe' value='johnny' checked>
<label for='johnny'>Johnny Doe</label>
</div>
<div>
<input type='radio' id='doe' name='doe' value='doe' checked>
<label for='doe'>An actual doe</label>
</div>
<br />
<div>
<label for='volume'>Volume</label>
<input type='range' name='volume' id='volume' min='0' max='11' />
</div>
</form>
<h3>Code</h3>
<p>
Below is some code, with a variable, you can copy it with
<kbd>Ctrl-C</kbd>. Did you know, <code>alert(1)</code> can show an alert
in JavaScript!
</p>
<code>var <var>myNumber</var> = 0;</code>
<pre><code>// This logs a message to the console and check out the scrollbar.<br>console.log('Hello, world!')</code></pre>
<p>Here are some more keyboard buttons</p>
<p>
Press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Print Screen</kbd> to take
a selected area screenshot on Linux.
</p>
<h3>Other</h3>
<p>
Here's a horizontal rule and image because I don't know where else to put
them.
</p>
<img src='https://placekitten.com/408/287' alt='Example kitten' />
<hr />
<p>And here's a nicely marked up table!</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Quantity</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>Godzilla</td>
<td>2</td>
<td>$299.99</td>
</tr>
<tr>
<td>Mozilla</td>
<td>10</td>
<td>$100,000.00</td>
</tr>
<tr>
<td>Quesadilla</td>
<td>1</td>
<td>$2.22</td>
</tr>
</tbody>
</table>
<h3>Typography</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque dictum
hendrerit velit, quis ullamcorper sem congue ac. Quisque id magna rhoncus,
sodales massa vel, vestibulum elit. Duis ornare accumsan egestas. Proin
maximus lacus interdum leo molestie convallis. Orci varius natoque
penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut
iaculis risus eu felis feugiat, eu mollis neque elementum. Donec interdum,
nisl id dignissim iaculis, felis dui aliquet dui, non fermentum velit
lectus ac quam. Class aptent taciti sociosqu ad litora torquent per
conubia nostra, per inceptos himenaeos.
<strong>This is strong,</strong> this is normal,
<b>this is just bold,</b> <em>and this is emphasized!</em> And heck,
<a href='/'>here</a>'s a link.
</p>
<blockquote
cite='https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote'
>
'The HTML blockquote Element (or HTML Block Quotation Element) indicates
that the enclosed text is an extended quotation. Usually, this is rendered
visually by indentation (see
<a
href='https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote#Usage_notes'
>Notes</a
>
for how to change it). A URL for the source of the quotation may be given
using the
<code>cite</code> attribute, while a text representation of the source can
be given using the <code><cite></code> cite element.'
<footer>
<cite>MDN, 'The Block Quotation element'</cite>
</footer>
</blockquote>
<q>Quotes (<q>) share the same style as blockquotes.</q>
<p>Use <mark> to <mark>highlight the important stuff</mark>.</p>
<ul>
<li>Unordered list item 1</li>
<li>Unordered list item 2</li>
<li>Unordered list item 3</li>
</ul>
<ol>
<li>Ordered list item 1</li>
<li>Ordered list item 2</li>
<li>Ordered list item 3</li>
</ol>
<p>Addresses are also styled to be <strong>awesome</strong>!</p>
<address>
<a href='mailto:john.doe@example.com'>john.doe@example.com</a><br />
<a href='tel:778-330-2389'>778-330-2389</a><br />
<a href='sms:666-666-6666'>666-666-6666</a><br />
</address>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
<p>The details and summary tag</p>
<details>
<summary>Click to Open...</summary>
<p>The HTML Details Element (details) creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. A summary or label can be provided using the summary element.</p>
</details>
<details open>
<summary>Click to Hide...</summary>
<p>The HTML Details Element (details) creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. A summary or label can be provided using the summary element.</p>
</details>
<footer>
Here is an example of a footer! Maybe you want to put some links here. <a href='#'>Privacy Policy</a> | <a href='https://github.com/kognise/water.css'>Contribute</a>
</footer>
/**
* Light-themed version:
* uses light theme by default but switches to dark theme
* if a system-wide theme preference is set on the user's device.
*
* Variables will remain uncompiled so the theme can update dynamically
* at runtime in the browser.
*/
:root {
--background-body: #ffffff;
--background: #efefef;
--background-alt: #f7f7f7;
--selection: #9e9e9e;
--text-main: #363636;
--text-bright: #000000;
--text-muted: #999999;
--links: #0076d1;
--focus: #0096bfab;
--border: #dbdbdb;
--code: #000000;
--animation-duration: 0.1s;
--button-hover: #dddddd;
--scrollbar-thumb: rgb(213, 213, 213);
--scrollbar-thumb-hover: rgb(196, 196, 196);
--form-placeholder: #949494;
--form-text: #000000;
--variable: #39a33c;
--highlight: #ffff00;
--select-arrow: url("data:image/svg+xml;charset=utf-8,%3C?xml version='1.0' encoding='utf-8'?%3E %3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' height='62.5' width='116.9' fill='%23161f27'%3E %3Cpath d='M115.3,1.6 C113.7,0 111.1,0 109.5,1.6 L58.5,52.7 L7.4,1.6 C5.8,0 3.2,0 1.6,1.6 C0,3.2 0,5.8 1.6,7.4 L55.5,61.3 C56.3,62.1 57.3,62.5 58.4,62.5 C59.4,62.5 60.5,62.1 61.3,61.3 L115.2,7.4 C116.9,5.8 116.9,3.2 115.3,1.6Z'/%3E %3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
:root {
--background-body: #202b38;
--background: #161f27;
--background-alt: #1a242f;
--selection: #161f27;
--text-main: #dbdbdb;
--text-bright: #ffffff;
--text-muted: #717880;
--links: #41adff;
--focus: #0096bfab;
--border: #dbdbdb;
--code: #ffbe85;
--animation-duration: 0.1s;
--button-hover: #324759;
--scrollbar-thumb: var(--button-hover);
--scrollbar-thumb-hover: rgb(20, 20, 20);
--form-placeholder: #a9a9a9;
--form-text: #ffffff;
--variable: #d941e2;
--highlight: #efdb43;
--select-arrow: url("data:image/svg+xml;charset=utf-8,%3C?xml version='1.0' encoding='utf-8'?%3E %3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' height='62.5' width='116.9' fill='%23efefef'%3E %3Cpath d='M115.3,1.6 C113.7,0 111.1,0 109.5,1.6 L58.5,52.7 L7.4,1.6 C5.8,0 3.2,0 1.6,1.6 C0,3.2 0,5.8 1.6,7.4 L55.5,61.3 C56.3,62.1 57.3,62.5 58.4,62.5 C59.4,62.5 60.5,62.1 61.3,61.3 L115.2,7.4 C116.9,5.8 116.9,3.2 115.3,1.6Z'/%3E %3C/svg%3E");
}
}
body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
line-height: 1.4;
max-width: 800px;
margin: 20px auto;
padding: 0 10px;
color: var(--text-main);
background: var(--background-body);
text-rendering: optimizeLegibility;
}
button, input, textarea {
transition: background-color var(--animation-duration) linear,
border-color var(--animation-duration) linear,
color var(--animation-duration) linear,
box-shadow var(--animation-duration) linear,
transform var(--animation-duration) ease;
}
h1 {
font-size: 2.2em;
margin-top: 0;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin-bottom: 12px;
}
h1,
h2,
h3,
h4,
h5,
h6,
strong {
color: var(--text-bright);
}
h1,
h2,
h3,
h4,
h5,
h6,
b,
strong,
th {
font-weight: 600;
}
q:before {
content: none;
}
q:after {
content: none;
}
blockquote , q{
border-left: 4px solid var(--focus);
margin: 1.5em 0em;
padding: 0.5em 1em;
font-style: italic;
}
blockquote > footer {
font-style: normal;
border: 0;
}
blockquote cite {
font-style: normal;
}
address {
font-style: normal;
}
a[href^='mailto']::before {
content: '📧 ';
}
a[href^='tel']::before {
content: '📞 ';
}
a[href^='sms']::before {
content: '💬 ';
}
mark {
background-color: var(--highlight);
border-radius: 2px;
padding: 0px 2px 0px 2px;
color: #000000;
}
button, select,
input[type='submit'],
input[type='button'],
input[type='checkbox'],
input[type='range'],
input[type='radio'] {
cursor: pointer;
}
input:not([type='checkbox']):not([type='radio']),
select {
display: block;
}
input,
button,
textarea,
select {
color: var(--form-text);
background-color: var(--background);
font-family: inherit;
font-size: inherit;
margin-right: 6px;
margin-bottom: 6px;
padding: 10px;
border: none;
border-radius: 6px;
outline: none;
}
input,
select,
button,
textarea {
-webkit-appearance: none;
}
textarea {
margin-right: 0;
width: 100%;
box-sizing: border-box;
resize: vertical;
}
select {
background: var(--background) var(--select-arrow) calc(100% - 12px) 50% / 12px no-repeat;
padding-right: 35px;
}
select::-ms-expand {
display: none;
}
select[multiple] {
padding-right: 10px;
background-image: none;
overflow-y: auto;
}
button,
input[type='submit'],
input[type='button'] {
padding-right: 30px;
padding-left: 30px;
}
button:hover,
input[type='submit']:hover,
input[type='button']:hover {
background: var(--button-hover);
}
input:focus,
select:focus,
button:focus,
textarea:focus {
box-shadow: 0 0 0 2px var(--focus);
}
input[type='checkbox'],
input[type='radio'] {
position: relative;
width: 14px;
height: 14px;
display: inline-block;
vertical-align: middle;
margin: 0;
margin-right: 2px;
}
input[type='radio'] {
border-radius: 50%;
}
input[type='checkbox']:checked,
input[type='radio']:checked {
background: var(--button-hover);
}
input[type='checkbox']:checked::before,
input[type='radio']:checked::before {
content: '•';
display: block;
position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
}
input[type='checkbox']:checked::before {
content: '✔';
transform: translateY(-50%) translateY(0.5px) translateX(-6px);
}
input[type='checkbox']:active,
input[type='radio']:active,
input[type='submit']:active,
input[type='button']:active,
input[type='range']:active,
button:active {
transform: translateY(2px);
}
input:disabled,
select:disabled,
button:disabled,
textarea:disabled {
cursor: not-allowed;
opacity: 0.5;
}
::-webkit-input-placeholder {
color: var(--form-placeholder);
}
::-moz-placeholder {
color: var(--form-placeholder);
}
::-ms-input-placeholder {
color: var(--form-placeholder);
}
::placeholder {
color: var(--form-placeholder);
}
fieldset {
border: 1px var(--focus) solid;
border-radius: 6px;
margin: 0;
margin-bottom: 6px;
padding: 10px;
}
legend {
font-size: 0.9em;
font-weight: 600;
}
input[type='range'] {
margin: 10px 0;
padding: 10px 0;
background: transparent;
}
input[type='range']:focus {
outline: none;
}
input[type='range']::-webkit-slider-runnable-track {
width: 100%;
height: 9.5px;
transition: 0.2s;
background: var(--background);
border-radius: 3px;
}
input[type='range']::-webkit-slider-thumb {
box-shadow: 0px 1px 1px #000000, 0px 0px 1px #0d0d0d;
height: 20px;
width: 20px;
border-radius: 50%;
background: var(--border);
-webkit-appearance: none;
margin-top: -7px;
}
input[type='range']:focus::-webkit-slider-runnable-track {
background: var(--background);
}
input[type='range']::-moz-range-track {
width: 100%;
height: 9.5px;
transition: 0.2s;
background: var(--background);
border-radius: 3px;
}
input[type='range']::-moz-range-thumb {
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
height: 20px;
width: 20px;
border-radius: 50%;
background: var(--border);
}
input[type='range']::-ms-track {
width: 100%;
height: 9.5px;
background: transparent;
border-color: transparent;
border-width: 16px 0;
color: transparent;
}
input[type='range']::-ms-fill-lower {
background: var(--background);
border: 0.2px solid #010101;
border-radius: 3px;
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
}
input[type='range']::-ms-fill-upper {
background: var(--background);
border: 0.2px solid #010101;
border-radius: 3px;
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
}
input[type='range']::-ms-thumb {
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
border: 1px solid #000000;
height: 20px;
width: 20px;
border-radius: 50%;
background: var(--border);
}
input[type='range']:focus::-ms-fill-lower {
background: var(--background);
}
input[type='range']:focus::-ms-fill-upper {
background: var(--background);
}
a {
text-decoration: none;
color: var(--links);
}
a:hover {
text-decoration: underline;
}
code, samp, time {
background: var(--background);
color: var(--code);
padding: 2.5px 5px;
border-radius: 6px;
font-size: 1em;
}
pre > code {
padding: 10px;
display: block;
overflow-x: auto;
}
var {
color: var(--variable);
font-style: normal;
font-family: monospace;
}
kbd {
background: var(--background);
border: 1px solid var(--border);
border-radius: 2px;
color: var(--text-main);
padding: 2px 4px 2px 4px;
}
img {
max-width: 100%;
height: auto;
}
hr {
border: none;
border-top: 1px solid var(--border);
}
table {
border-collapse: collapse;
margin-bottom: 10px;
width: 100%;
}
td,
th {
padding: 6px;
text-align: left;
}
thead {
border-bottom: 1px solid var(--border);
}
tfoot {
border-top: 1px solid var(--border);
}
tbody tr:nth-child(even) {
background-color: var(--background-alt);
}
::-webkit-scrollbar {
height: 10px;
width: 10px;
}
::-webkit-scrollbar-track {
background: var(--background);
border-radius: 6px;
}
::-webkit-scrollbar-thumb {
background: var(--scrollbar-thumb);
border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--scrollbar-thumb-hover);
}
::-moz-selection {
background-color: var(--selection);
}
::selection {
background-color: var(--selection);
}
details {
display: flex;
flex-direction: column;
align-items: flex-start;
background-color: var(--background-alt);
padding: 10px 10px 0;
margin: 1em 0;
border-radius: 6px;
overflow: hidden;
}
details[open] {
padding: 10px;
}
details > :last-child {
margin-bottom: 0;
}
details[open] summary {
margin-bottom: 10px;
}
summary {
display: list-item;
background-color: var(--background);
padding: 10px;
margin: -10px -10px 0;
}
details > :not(summary) {
margin-top: 0;
}
summary::-webkit-details-marker {
color: var(--text-main);
}
footer {
border-top: 1px solid var(--background);
padding-top: 10px;
font-size: 0.8em;
color: var(--text-muted);
}
/*# sourceMappingURL=light.css.map */
Also see: Tab Triggers