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.
<header>
<h1>HTML5 Example Page</h1>
</header>
<nav>
<ul>
<li><a href="">Home</a></li>
<li><a href="">About</a></li>
<li><a href="">Contact</a></li>
</ul>
</nav>
<article>
<h2>This is a headline</h2>
<p>
This paragraph is nested inside an article. It contains basic tags like <a href="#top">anchors</a>,
<strong>strong</strong>, <em>emphasis</em>, and <u>underline</u>.
It provides <del>deleted text</del> as well, which often gets replaced with <ins>inserted</ins> text.
</p>
<h3>This is subheadline for more content</h3>
<ul>
<li>Unordered lists have basic styles</li>
<li>They use the circle list style
<ul>
<li>Nested list item one</li>
<li>Nested list item two</li>
</ul>
</li>
<li>Just one more list item</li>
</ul>
<ol>
<li>Ordered lists also have basic styles</li>
<li>They use the decimal list style
<ul>
<li>Nested list item one</li>
<li>Nested list item two</li>
</ul>
</li>
<li>Last list item</li>
</ol>
</article>
<aside>
<h3>This is some advanced content</h3>
<figure>
<img data-src="/assets/images/image.png"
src="data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=="
width="360" height="120" alt="Description of the image"/>
<figcaption>Caption for the first image</figcaption>
</figure>
<a href="">
<figure>
<img data-src="/assets/images/image2.png"
src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="
width="360" height="80" alt="Description of the image"/>
<figcaption>Caption for the second image</figcaption>
</figure>
</a>
<p>
<a class="button" href="#">Anchor button</a><br>
<button>Button element</button>
</p>
<blockquote>
“Infamous quote”
<footer><cite>- Attribution</cite></footer>
</blockquote>
<hr>
<details>
<summary>Expandable title</summary>
<p>Revealed content</p>
</details>
<details>
<summary>Another expandable title</summary>
<p>More revealed content</p>
</details>
<h4>This is a code example</h4>
<pre><code>.some-class {
background-color: red;
}</code></pre>
</aside>
<section>
<h2>This is another headline</h2>
<div class="some-class">
This is a boxed element.
</div>
<div class="some-class">
This is yet another boxed element.
</div>
<h3>This is a table</h3>
<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>And this is a form</h3>
<form>
<div class="row">
<label for="exampleSubject">Subject</label>
<input type="text" placeholder="Your subject" id="exampleSubject">
</div>
<div class="row">
<label for="exampleMessage">Message</label>
<textarea placeholder="Your message" id="exampleMessage"></textarea>
</div>
<div class="row">
<label>
<input type="checkbox" id="exampleConfirmation"><span>Confirmation</span>
</label>
</div>
<input type="submit" value="Submit">
</form>
</section>
<footer>
Made with <a href="https://html5example.com">html5example.com</a>
</footer>
/*
Remove and add the import statement to compare the default browser styles to the barebone stylesheet
*/
@import url("https://cdn.jsdelivr.net/gh/pixelbrackets/barebone-stylesheet/dist/barebone.min.css");
Also see: Tab Triggers