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 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.
<!-- a single-line comment in HTML -->
<!--
a multi-line comment in HTML (they are the same)
These WILL be visible in the page source,
but not as content on the page.
-->
<h1>This is the <e>h1</e> element. It represents the <strong>most important</strong> piece of content on the page.</h1>
<p>A <e>p</e> element describes a paragraph of text. Paragraphs break up text into collected blocks of associated sentences. You may have noticed the <e>e</e> element here. We just made that up. It's so that we can style the element tag name and make it stand out. try your best to ignore them. Use the radio button above to highlight the different the elements of different display type!</p>
<h2>This is the <e>h2</e> element. It represents a level of importance one below the heading level 1</h2>
<p>You may use additional levels of heading to break the article into meaninful sections. You may have many equally important levels of heading depending on the subject matter and the manner in which the content was designed.</p>
<p>The <e>h1</e>, <e>p</e>, <e>h2</e>, <e>ul</e>, and <e>li</e> elements are all "Block" level elements. This means that they come into the world with a specific set of defaults. Generally, they are <code>display: block;</code>, and <code>width: 100%;</code>. They take up the full width of their parent element and generally stack like a layered cake.</p>
<p>There are also interactive form elements such as checkboxes and 'radio' buttons. These get a little more complex and so, for now - just know that most of them are inline elements to start out. The <e>form</e> elements helps describe user interactions and collects the various <e>input</e> elements together.</p>
<h2>This is and equally important <e>h2</e> element.</h2>
<p>Many times, there is an introduction-like paragraph below a heading to set the stage for the following content. You may have a list</p>
<ul>
<li>Lists are great for listing things.</li>
<li>Their name really says it all.</li>
<li>The <e>ol</e> and <e>ul</e> elements describe an "ordered" or "unordered" list.</li>
<li>The <e>li</e> element describes the list item itself.</li>
<li>Each "child" element (in this case the <e>li</e>) will be formatted with 1 indent.</li>
<li>These elements are "nested" and should appear so by way of formatting to help the humans keep track of things.</li>
</ul>
<h3>When you require a subheading for content within the level 2 context, you can use this level 3 heading. The <e>h3</e> element does the trick.</h3>
<p>Inside a block-level content element such as a <e>p</e>, you can employ the various "inline" elements. These are elements which come into being with a different set of default properties. <a href="#">Links</a> are inline. You can use <em>emphasis</em> or <strong>strong</strong> emphasis. You can use that <code>code</code> element you saw up above - and a whole bunch of other useful ways to describle parts of a heading or paragraph like the <mark>mark</mark> element.</p>
<p>You <em>could</em> even break up a sentence into arbitrary <e>span</e>s or text <span>like this</span> and <span>this</span> - even down to the very <span>c</span><span>h</span><span>a</span><span>r</span><span>a</span><span>c</span><span>t</span><span>e</span><span>r</span><span>s</span>.</p>
<p>"Inline" elements fall in a row and wrap around as needed.</p>
<h3>You could use an <e>h3</e> as a heading for a list of "Articles."</h3>
<ol>
<li>
<article>
<h1>Lists aren't just about bullets.</h1>
<p>They can be filled with whatever content you like.</p>
<p>However, you must note that only list items belong as direct children of the list itself</p>
</article>
</li>
<li>
<article>
<h1>You <em>could</em> have a list of forms.</h1>
<p>You could have a list of lists!</p>
</article>
</li>
</ol>
<h2>Also! Remember that just because the browser creators decided that <e>h1</e> and <e>h2</e> elements were visually "large" and "emboldened" - doesn't mean they are. These elements are for describing. That does not mean <em>visually</em>.</h2>
<p>Pretend that you are writing your HTML for the computer. The content is for the human... but the markup is to describe it to the computer. What if Siri or Alexa needs to read it? They don't care how it looks. Write the HTML properly, and then worry about the human eyes in the CSS.</p>
<p>But hey, it'll never be perfect. You'll always end up taking on a few generic content divisions.</p>
<div>You may need a <e>div</e> element to describe a group of elements that need to be divided.</div>
Also see: Tab Triggers