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 class="site-header">
<div class="max-width">
<h1 class="heading__primary">HTML Cheat Sheet</h1>
<h2 class="heading__secondary">
<div>Hyper</div>
<div>Text</div>
<div>Markup</div>
<div>Language</div>
</h2>
<nav class="toggle-nav">
<a href="#" data-toggle="all" class="active">All</a>
<a href="#" data-toggle="document">Document Elements</a>
<a href="#" data-toggle="container">Container Elements</a>
<a href="#" data-toggle="content">Content Elements</a>
</nav>
</div>
</header>
<main class="site-content">
<article class="content-section" id="document">
<header class="content-section__header">
<div class="max-width">
<h1 class="heading__tertiary">Document Elements</h1>
</div>
</header>
<div class="max-width">
<p class="description">Document elements create the basic outline of a website. While they are required to build a website, if you are building a website in CodePen you do not need to include these tags.
</p>
<table class="content-section__table">
<thead>
<tr>
<th>Tag</th>
<th>Use</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="code code--pink"><html></html></code></td>
<td>Wraps around <strong>all</strong> of the content of a web page. Says that everything inside is marked-up with HTML.</td>
</tr>
<tr>
<td><code class="code code--pink"><head></head></code></td>
<td>Wraps around information about a web page. Code in the <code>head</code> element is not visible on the page.</td>
</tr>
<tr>
<td><code class="code code--pink"><body></body></code></td>
<td>Wraps around a the content in a web page. This is the visible part of the web page. When adding markup to CodePen you are adding code to the <code>body</code> element.</td>
</tr>
</tbody>
</table>
</div>
</article>
<article class="content-section" id="container">
<header class="content-section__header">
<div class="max-width">
<h1 class="heading__tertiary">Container Elements</h1>
</div>
</header>
<div class="max-width">
<p class="description">Container elements wrap around chunks of content. Specific elements give extra meaning to the content while generic elements don’t give any additional meaning.</p>
<h3 class="heading__quaternary">Specific Containers</h3>
<table class="content-section__table">
<thead>
<tr>
<th>Tag</th>
<th>Use</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="code code--pink"><header></header></code></td>
<td>Holds the introduction content to an entire web page or section of content.</td>
</tr>
<tr>
<td><code class="code code--pink"><nav></nav></code></td>
<td>Holds a group of links.</td>
</tr>
<tr>
<td><code class="code code--pink"><main></main></code></td>
<td>Holds the main content of a web page, the stuff people are there to read.</td>
</tr>
<tr>
<td><code class="code code--pink"><section></section></code></td>
<td>Wraps around a group of related content.</td>
</tr>
<tr>
<td><code class="code code--pink"><article></article></code></td>
<td>Wraps around a group of content. Examples can be blog posts, news articles, or even individual comments.</td>
</tr>
<tr>
<td><code class="code code--pink"><aside></aside></code></td>
<td>Wraps around groups of content that aren’t required to fully understand the main content of the page. An example would be content in a sidebar.</td>
</tr>
<tr>
<td><code class="code code--pink"><footer></footer></code></td>
<td>Holds the footer content to an entire web page or section of content.</td>
</tr>
</tbody>
</table>
<h3 class="heading__quaternary">Generic Containers</h3>
<table class="content-section__table">
<thead>
<tr>
<th>Tag</th>
<th>Use</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="code code--pink"><div></div></code></td>
<td>Creates a block element with no semantic meaning.</td>
</tr>
<tr>
<td><code class="code code--pink"><span></span></code></td>
<td>Creates an inline element with no semantic meaning.</td>
</tr>
</tbody>
</table>
<p>For more information about block elements and inline elements visit the <a href="bit.ly/gcc-glossary" target="_blank">Glossary or Terms</a>.</p>
</div>
</article>
<article class="content-section" id="content">
<header class="content-section__header">
<div class="max-width">
<h1 class="heading__tertiary">Content Elements</h1>
</div>
</header>
<div class="max-width">
<p class="description">Content elements give meaning to the different types of content on a web page.</p>
<table class="content-section__table">
<thead>
<tr>
<th>Tag</th>
<th>Use</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="code code--pink"><h1></h1></code><br />
<code class="code code--pink"><h2></h2></code><br />
<code class="code code--pink"><h3></h3></code><br />
<code class="code code--pink"><h4></h4></code><br />
<code class="code code--pink"><h5></h5></code><br />
<code class="code code--pink"><h6></h6></code>
</td>
<td>Creates a hierarchy of headings with h1 being the largest and h6 being the smallest.</td>
</tr>
<tr>
<td><code class="code code--pink"><p></p></code></td>
<td>Wraps around a paragraph of text.</td>
</tr>
<tr>
<td><code class="code code--pink"><a <span class="code--purple">href="<span class="code--blue">http://website.com</span>"</span>><span class="code--black">Link Text</span></a></code></td>
<td>An anchor element wraps around text to become a link. Requires the <code>href</code> attribute which specifies where the text links to.</td>
</tr>
<tr>
<td><code class="code code--pink"><blockquote></blockquote></code></td>
<td>For quoted text, usually indents text from both sides.</td>
</tr>
<tr>
<td><code class="code code--pink"><ol></ol></code></td>
<td>Wraps around a group of list items to create an ordered list.</td>
</tr>
<tr>
<td><code class="code code--pink"><ul></ul></code></td>
<td>Wraps around a group of list items to create an unordered list.</td>
</tr>
<tr>
<td><code class="code code--pink"><li></li></code></td>
<td>Creates an individual list item. All list items must be contained in either an ordered or unordered list element.</td>
</tr>
<tr>
<td><code class="code code--pink"><img <span class="code--purple">src="<span class="code--blue">image.jpg</span>" alt="<span class="code--blue">An Image</span>"</span> /></code></td>
<td>Img elements are used to display images. Requires the <code>src</code> attribute which specifies the url of the image and the <code>alt</code> attribute which provides descriptive text. This is a self-closing tag.</td>
</tr>
<tr>
<td><code class="code code--pink"><br /></code></td>
<td>A break tag inserts a line break in a chunk of text. Often used inside of a paragraph tag. This is a self-closing tag.</td>
</tr>
<tr>
<td><code class="code code--pink"><hr /></code></td>
<td>A horizontal tag inserts a horizontal rule (line). This is a self-closing tag.</td>
</tr>
</tbody>
</table>
</div>
</article>
</main>
<footer class="site-footer">
<div class="max-width">
<p>This site is for educational purposes in connection with the <a href="https://www.gswo.org/">Girl Scouts of Western Ohio</a>. All image rights are retained solely by the original sources. Learn more at <a href="http://girlscancode.io">Girls Can Code</a>.</p>
</div>
</footer>
Also see: Tab Triggers