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 URL's 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 it's URL and the proper URL extention.
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.
<main id="main-doc">
<body>
<nav class="left" id="navbar">
<header class="nav-header">HTML Basics</header>
<a class="nav-link" href="#Introduction">Introduction</a>
<a class="nav-link" href="#Elements">Elements</a>
<a class="nav-link" href="#Headers">Headers</a>
<a class="nav-link" href="#Paragraphs">Paragraphs</a>
<a class="nav-link" href="#Anchors">Anchors</a>
<a class="nav-link" href="#Lists">Lists</a>
<a class="nav-link" href="#Dividers">Dividers</a>
<a class="nav-link" href="#Images">Images</a>
<a class="nav-link" href="#Horizontal_Rules">Horizontal Rules</a>
<a class="nav-link" href="#Reference">Reference</a>
</nav>
<section class="main-section" id="Introduction">
<header class="section-headers">
Introduction
</header>
<p>
HTML(Hypertext Markup Language) is a standarized markup language that defines the structure of web pages.
HTML was initially released in 1993 as a way for people that weren't experienced in SGML(Standard Generalized Markup Language) to exchange and publish technical documents.
Today HTML is most commonly used by web developers in order to create and service websites and web applications.
There are many different elements that are used within HTML but this guide will only be covering the basics.
</p>
</section>
<section class="main-section" id="Elements">
<header class="section-headers">
Elements
</header>
<p>
An element is an individual component in HTML document. Elements represent a meaning for that particular component on the document and we will go over the basics throughout this guide.
Each element in HTML can also have attributes attached to them. Some are specific for certain elements and some are global like these:
<ul>
<li><code>id</code> - Denotes the unique ID of an element in a page.</li>
<li><code>class</code> - Denotes a CSS class of an element which can be used to style multiple elements together.</li>
<li><code>style</code> - Denotes the style(s) to apply to an element.</li>
</ul>
</p>
</section>
<section class="main-section" id="Headers">
<header class="section-headers">
Headers
</header>
<p>
With headers, you have 6 different types you can choose from. Starting from <code>h1</code> all the way down to <code>h6</code>.
The topmost heading in HTML is <code>h1</code> and will have the largest text while <code>h6</code> will be the most inner heading with the smallest text.
</p>
</section>
<section class="main-section" id="Paragraphs">
<header class="section-headers">
Paragraphs
</header>
<p>
The <code>p</code> tag represents a paragraph.
Paragraphs are usually used to represent blocks of text but can also be used as strutcural grouping of related content like images or forms.
</p>
</section>
<section class="main-section" id="Anchors">
<header class="section-headers">
Anchors
</header>
<p>
The <code>a</code> tag represents an anchor. Anchors are used as a piece of text that marks the beginning and/or end of a hypertext link.
Anchor tags have many different attributes but we will just be going over the two most common below:
<ol>
<li><code>href</code> - href refers to a destination provided by the link such as another page on the website or another website altogether</li>
<li><code>name</code> - name is used as an identifier for many elements including anchors. Identifiers are used for styling an element in CSS and in anchors they can be used to allow another document to reference that anchor by using the unique identifier</li>
</ol>
All attributes are optional, however, without an <code>href</code> or <code>name</code> attribute, the <code>a</code> tag will not be useful.
</p>
</section>
<section class="main-section" id="Lists">
<header class="section-headers">
Lists
</header>
<p>
Lists are groups of related items. There are three different kinds of lists in HTML: <code>ul</code>, <code>ol</code>, and <code>dl</code>.
<ul>
<li><code>ul</code> is an unordered list and is used to group related items in no particular order. Each list item in an unordered list is defined with <code>li</code> and will be represented with bullets.</li>
<li><code>ol</code> is an ordered list and is used to group related items in a set order. Each list item in an ordered list is defined with <code>li</code> as well but will be represented with numbers.</li>
<li><code>dl</code> is a description list and is used to list terms while also providing a description of each term. Each term will be defined with a <code>dt</code> tag and the description for each term will be defined with a <code>dd</code>.</li>
</ul>
We've seen examples of both unordered lists and ordered lists but let's take a look at an example of a description list below:
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
</p>
</section>
<section class="main-section" id="Dividers">
<header class="section-headers">
Dividers
</header>
<p>
Dividers, or more commonly known as divs, are used to define a division or a section.
The <code>div</code> tag is used to create the container in which we place HTML elements.
The <code>div</code> tag is easily styled using a class or id attribute which are similar to the name attribute we saw earlier.
Divs can be used as a container for any sort of content, which makes them a versatile tool when writing HTML.
</p>
</section>
<section class="main-section" id="Images">
<header class="section-headers">
Images
</header>
<p>
The <code>img</code> tag is used to embed an image into a website. The <code>img</code> tag is empty with only attributes and does not require a closing tag.
The <code>img</code> tag has two required attributes:
<ul>
<li><code>src</code> - which specifies the path to the image(where the image is coming from)</li>
<li><code>alt</code> - which provides alternative text for the image in case the image doesn't load as intended and for accessibility purposes</li>
</ul>
</p>
</section>
<section class="main-section" id="Horizontal_Rules">
<header class="section-headers">
Horizontal Rules
</header>
<p>
The <code>hr</code> tag represents a thematic break which is used to separate paragraph level elements. A common use for the <code>hr</code> tag is to separate differents topics within a website.
Horizontal rules are visually represented by a horizontal line across the website.
</p>
</section>
<section class="main-section" id="Reference">
<header class="section-headers">
Reference
</header>
<p>
All documentation in this page is taken from <a href="https://www.w3schools.com/html/default.asp" target="_blank">w3schools</a> and <a href="https://en.wikipedia.org/wiki/HTML" target="_blank">Wikipedia</a>.
</p>
</section>
</body>
</main>
html {
scroll-behavior: smooth;
}
h2 {
padding: 10px;
}
body {
background-color: #001e38;
color: white;
}
.left {
height: 100%;
width: 200px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: rgb(255, 255, 255);
overflow-x: hidden;
padding-top: 20px;
border-right: black;
border-width: 1px;
border-style: solid;
background-color: #010c1e;
}
.left a {
padding: 6px 8px 6px 16px;
text-decoration: none;
font-size: 25px;
color: rgb(255, 255, 255);
display: block;
}
.left a:hover {
color: rgb(177, 73, 168);
}
.main-section {
margin-left: 200px;
padding: 0px 10px;
}
@media screen and (max-height: 450px) {
.left {padding-top: 15px;}
.left a {font-size: 18px;}
}
.section-headers {
font-size: 30px;
}
.nav-header {
font-size: 26px;
display: block;
padding: 6px 8px 6px 16px;
}
.nav-link {
border-top: solid 1px white;
border-bottom: solid 1px white;
}
.nav-link:last-child {
border-bottom: none;
}
#navbar {
border: solid 1px white;
}
// !! IMPORTANT README:
// You may add additional external JS and CSS as needed to complete the project, however the current external resource MUST remain in place for the tests to work. BABEL must also be left in place.
/***********
INSTRUCTIONS:
- Select the project you would
like to complete from the dropdown
menu.
- Click the "RUN TESTS" button to
run the tests against the blank
pen.
- Click the "TESTS" button to see
the individual test cases.
(should all be failing at first)
- Start coding! As you fulfill each
test case, you will see them go
from red to green.
- As you start to build out your
project, when tests are failing,
you should get helpful errors
along the way!
************/
// PLEASE NOTE: Adding global style rules using the * selector, or by adding rules to body {..} or html {..}, or to all elements within body or html, i.e. h1 {..}, has the potential to pollute the test suite's CSS. Try adding: * { color: red }, for a quick example!
// Once you have read the above messages, you can delete all comments.
Also see: Tab Triggers