1. HTML
Table of Contents
Key Concepts
HTML (Hypertext Markup Language) is a markup language that describes the content and structure of a webpage.
HTML elements are created using opening and closing tags (e.g.,
<p>content</p>).Self-closing tags (void tags) like
<img />do not require a closing tag.Attributes provide additional information and are included in the opening tag (e.g.,
href,src,alt).Elements can be nested inside other elements to create structure (e.g.,
<li>elements must be inside<ul>or<ol>).A properly formatted HTML document includes
<!DOCTYPE html>,<html>,<head>, and<body>tags.Semantic elements have names that describe their function (e.g.,
header,main,footer,nav,section,figure).A Browser is a program that interprets and renders HTML.
Browsers use the
file://protocol when opening HTML files locally; thehttps://protocol is used when accessing files from a server over the internet.
Why HTML Matters for JavaScript Developers
You've been building applications that run in the terminal using Node.js. These CLI apps take input, process data, and output results to the console. Now you're going to learn how to build applications with HTML, CSS, and JavaScript that run in a web browser instead.
You already know how to:
Create and manipulate data with JavaScript
Build classes to model real-world systems
Handle user input in the terminal
HTML gives you a new environment to apply these skills: the browser. Instead of console.log() displaying text in the terminal, you'll create visual interfaces that users can see and interact with in a browser window.
The Browser vs. Node
Text-based interface
Visual interface
Input via prompt-sync
Input via forms, buttons, clicks
Output via console.log()
Output via updating HTML elements
Runs on your computer in the Terminal
Runs in user's browser
HTML is a Markup Language
Unlike JavaScript which is a programming language, HTML is a markup language. Markup languages like HTML are not used for executing logic, but instead are used to annotate text with symbols to define the content and presentation of a document.
For example, in the markup language Markdown (written in .md files), we can annotate text a hashtag (#) to make a heading, use double-asterisk symbols ** to display text as bold, and use - to create bullet lists:
HTML Syntax: Tags and HTML Elements
HTML (Hypertext Markup Language) is the markup language used to define the content and presentation of webpages. In HTML, the syntax to create those same elements above looks like this:
Every pair of opening tag and closing tag (e.g. <h1></h1>) create an HTML element—the most basic building block of a webpage.
Here are some key details to note about HTML elements:
The tag name (e.g.
h1,h2,pstrong,ul,li) determine how the content of that element will be rendered by the browser.Only the content between the tags is displayed to the user.
Comments are written like so:
<!-- comment -->HTML elements are presented in order from top to bottom.
TODO: Delete the contents of the HTML file and create the following:
A
h1element with your nameA
pelement with a brief statement of who you are ("Student at The Marcy Lab School")A
h2element with the text content "Programming Skills"A
ulwith list items (li) for each module we've covered:Command Line & Git
JavaScript Fundamentals
Object-Oriented Programming
Viewing HTML Files In Your Browser
To view an HTML file in your browser, all you have to do is drag and drop the index.html file from VS Code into your browser's tab bar. Your browser will automatically interpret the HTML syntax and "render" (display) the elements.

If you try doing this with the index.md file, you'll see that your browser will not be able to render other kinds of markup files.
At the end of the day, your browser is just a program for interpreting and rendering HTML. It can also interpret/render CSS and execute JavaScript!
A Quick Note On Headings
The heading elements h1 through h6 are used to indicate the start of a new section. When choosing which heading size to use, think of it like a book:
h1is the book title. There should only be one and it should be the first heading you see.h2elements are chapter titles and come at the top of each new section of content.h3elements are like subsection titles within chapters.Headings
h4,h5, andh6also exist but they are rarely necessary.
Screen readers use this hierarchy to help users navigate our website in a logical order, so it's important to use headings in order (don't skip from h1 to h4 without h2 and h3 in between).
Consider this example:
Attributes
Some HTML elements require attributes—additional pieces of information used to configure an element. The two most common examples of elements that use attributes are hyperlinks and images.
Hyperlinks
A hyperlink is an element that lets the user navigate from one page to another by clicking on some text. Hyperlinks are made with the "anchor" tags <a></a> and use the "hyperlink reference" attribute href:
In this example, href ("hyperlink reference") is the attribute which defines where the link will take the user. The text Home, Projects, and Contact Me is what the user sees and can click on to navigate.
Remember, attributes like href are always added to the opening tag of an HTML element.
TODO: Add the hyperlink elements above to your index.html file. Then, add them in the projects.html and contact.html files as well.
Remember to refresh! After saving changes to your HTML file, refresh the browser (Cmd+R on Mac or Ctrl+R on Windows) to see your updates. You'll be doing this constantly as you build!
Images
Images use the <img> tag with two important attributes:
src— the source URL or file path of the imagealt— describes the image for screen readers and when images fail to load
Notice <img /> is a self-closing tag (or void tag)—it doesn't need a closing tag.
TODO: Go to your GitHub profile. Right-click your profile image and select Copy Image Address. Add an image with your profile picture to your index.html file.
If you don't have a GitHub profile picture, make sure to upload one!
Structural Elements: Nesting
This use of container elements is a key concept in HTML: elements are often nested inside one another to build the hierarchy and organization of your web page.
For example, when building lists in HTML, it's important to remember that <li> elements (list items) must always be placed inside a container element—either an unordered list (<ul>) or an ordered list (<ol>).
The browser does not allow you to just use <li> by itself; it requires a parent list element to create the proper structure. The type of parent list element determines how the list item is displayed.
TODO: Try changing the ul to an ol and see how the browser changes the presentation of the list items:
You can nest many types of elements within others. For instance, in the previous code, a <strong> element is used inside a paragraph (<p>) element to make certain words bold. This demonstrates how nesting allows you to mix and match different HTML elements to achieve the formatting and layout you want.
Inspecting the HTML Structure: HTML Boilerplate
If you ever want to see the underlying HTML structure of a rendered webpage, you can right click on the page and select Inspect. This will open the Chrome Developer Tools which looks like this:

With the Chrome Developer Tools, you can look closely at each element and see how it is rendered. When we learn more about CSS, the Chrome Developer tools will become very important.
For now, notice that a few additional structural elements have been added to the document that we did not create:
htmlheadbody
These elements are structural elements that the browser will add to create a properly formatted HTML document. While they are technically optional, they should be included in every HTML document that we create.
In fact, every HTML document should start with the same "boilerplate" code:
Let's break this down:
<!DOCTYPE html>immediately tells the browser that it is rendering an HTML document<html>acts as the top-level container for all HTML elements. We also specify the language is english (which you can change!)<head>contains "meta data" (information about the website) that won't show up in the webpage itself<meta>elements define specific configurations for the website<title>determines what shows up in the browser tab as well as what appears in search results
<body>contains all of the elements that the user will see on the webpage. All of the content you've created should go inside of thebody
TODO: In the index.html file, use the emmet abbreviation html:5 trick to insert the boilerplate code. Then, copy-paste all of the content you've already created into the body. Finally, update the title inside of the head to your name. Do the same for the projects and contact pages
Remember to refresh! After saving changes to your HTML file, refresh the browser (Cmd+R on Mac or Ctrl+R on Windows) to see your updates. You'll be doing this constantly as you build!
Accessible Web Design
How we structure our HTML does more than just keep our code organized—it has a tangible impact on users with disabilities who rely on tools like screen readers to navigate a webpage.
We've already done a good job at this by:
Using headings (
h1,h2, etc.) in the proper order.Using descriptive link names in our anchor tags
<a>.Adding the
altattribute to our image.
But there are a few more ways we can improve our HTML structure. Let's see how by building a profile page like this:

Semantic Page Structure
Most webpages have three main parts:
Header — Contains navigation, logo, or introductory content at the top of the page.
Main Content — Contains the primary content of the page.
Footer — Contains copyright, contact info, or secondary links at the bottom of the page.
In HTML, there are semantic elements made specifically for these areas of content:
Rather than adding visible content to the page, these elements provide structure that will keep our page organized.
TODO: Start by adding in these sections to your body.
Header Navigation
Our header typically includes navigation links to the other pages in the site. However, rather than just using <a> tags on their own, we can make our navigation hyperlinks in our header more accessible by wrapping them in a nav element:
This helps screen readers quickly find the navigation links.
Footer
The footer typically contains copyright information or other contact information. For this website, we just want to add a copyright and a way to help our users learn more about Marcy!
See if you can figure out the HTML for yourself before checking the solution below
Main Sections
Using the appropriate sized headings (h1, h2, etc.) helps to make our main content more navigable. However, we can improve things by using section elements to contain each sub-grouping of content.
In between our navigation links in the header and the information in the footer, try to identify the different sections within the main content of the page before checking the answer below (hint: look at the headings)
Now that we've identified the sections, inside of the main element, create a section element for each section of content.
Challenge: Main Sections
Before moving on, use the HTML skills that you have learned in this lesson to fill out each of our main sections. Use the screenshot above to see what you're trying to build.
Figure and Figcaption
Finally, for the most accessible user experience with our images, we should put our images inside of a <figure> element with a figcaption to describe the picture.
Check out how we can do this in the "Hero" section:
<figure> is another semantic element used to structure our image content. It groups an image with its caption. The <figcaption> provides useful context for the image.
Deep Dive: The file:// protocol vs the https:// protocol
file:// protocol vs the https:// protocolThis entire time, we've been viewing the index.html file in our browser which we opened directly from VS Code. Take a look at the URL Bar.
You're probably familiar with seeing https:// at the start of your URL bar, but not file://.

When using your browser on the internet, the https:// protocol (hypertext transfer protocol) is used to load HTML files from a server.

A server is any computer that provides a resource to another computer.
Your browser uses the file:// protocol to retrieve HTML files that come from your file system on your own computer. It all happens on the same computer:

Whether you're loading a file locally or from a server, your browser is doing the same thing—receiving and rendering HTML. Later, we'll learn to build servers so others can access our content via https://. For now, we'll use file:// to view files on our own computer.
Quiz
Q1: What is the difference between a markup language and a plain text file?
Q2: What is the difference between the file:// protocol and the https:// protocol?
Q3: What are the four errors in the HTML below?
Q4: What is wrong with this image element? How would you fix it?
Q5: Create an anchor tag that links to https://google.com with the visible text "Search on Google".
Q6: What are the three semantic elements that structure the main parts of a webpage, and what does each contain?
Q7: Rewrite the following HTML using semantic elements instead of <div> tags:
Complete HTML
Here's the complete HTML with all the elements we've built. Use this as a reference to check your work or catch up if you fell behind.
index.html
The projects file and the contacts file have been updated with the proper boilerplate structure and semantic elements.
projects.html
contact.html
Last updated
