2 Basics of HTML Part I Class Note
2 Basics of HTML Part I Class Note
• Knowing how to code in any language is a valuable skill. Despite how complex websites
may be, they are still built with the fundamental blocks of the web, HTML. HTML and CSS
are the frameworks used to build websites. If you can understand how they work together,
you’re much better off when it comes to building websites.
• What is HTML?
▪ It is just a standardized system of tagging a text file
▪ A text file that is "tagged" following the "HTML standard" is called an HTML
document
▪ Both web developers and web browsers follow this standard to generate expected
outcomes
• HTML versions
▪ There are 5 versions of HTML so far, from HTML 1.0 to the most recent one,
HTML5.
• DOCTYPE
▪ It is not an HTML tag. It is just an instruction for your browser to tell what version
of HTML your document is using
▪ DOCTYPE declarations:
• For HTML5, use this only: <!DOCTYPE html>
• For HTML 4: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
4.01//EN" http://www.w3.org/TR/html4/strict.dtd>
• For this course, you only need to focus on HTML5. Reasons:
▪ Browsers understand earlier versions anyways
▪ HTML5 is simplified
▪ HTML5 has better error handling ways
▪ HTML5 has multimedia elements, meaning, browsers that support HTML 5 are also
media players for video and audio
▪ Includes semantic content by including <header> <footer>, <article>, <section> and
<figure>
• Purpose of learning HTML
▪ The main purpose of learning HTML is to know how to properly tag your text
documents in a way that the browser understands what you are trying to accomplish.
Ex. If you are trying to include a title in the text document, how do you say it is a
title. Or, if you want to include a paragraph, how do you say it is a paragraph and so
on. To do this, you just follow the standard that browsers can understand.
2.3 How to write HTML code in VSC
• Here are the most common tasks you do using Visual Studio Code
▪ Open existing folder or file
▪ Create a new folder in a specific location
▪ Create a new file in a specific location
▪ Make edits and save
▪ Rename files and/or folders
• Here is a list of VSC extensions (add extra feature to VSC) you must install:
▪ Open in default browser (by peakchen90): to fast open html file in browser
▪ Live Server (by Ritwick Dey): Launch a development local Server with live reload
feature for static & dynamic pages
▪ Material icon theme (by Philipp Kief): provides lots of icons based on Material
Design for VSC
▪ Prettier (by Prettier): a tool that automatically makes your code more readable or
formatted
▪ Auto rename tag (by Jun Han): automatically renames paired HTML/XML tags
▪ CSS Peek (by Pranay Prakash): to check the properties attached to a css class or id
from your HTML file. With CSS Peek, you can view a hover image of your CSS
from within you HTML file.
▪ Bracket colorizer (by CoenraadS): for colorizing matching brackets
▪ Indent rainbow (by Odewart) : makes indentation easier to read
▪ JS Snippet (by Gajesh Panigrahi) Javascript, typescript, bootstrap, ES6, typescript-
react, react, react-router code snippet
2.4 Basic rules of HTML tags
• Why do HTML tags do? Tags provide web browsers with instructions about the type of the
texts included in the html document. HTML tags are the hidden keywords within a web page
that define how your web browser must format and display the content. For example,
o <h1> h1 means this text is a header </h1>
o <p> p means this text is a paragraph <p/>
• What are rules of HTML tags?
o 1. Tags are always enclosed in angle brackets: < > Ex: look how this paragraph
tag is enclosed with angle bracket: <p>
o 2. Tags usually come in pairs: An opening tag and a closing tag. Ex. Paragraph
tag <p> Content of the <b>paragraph</b> goes in between the
opening and the closing tag. </p>
▪ The opening paragraph (<p>) tag indicates where the paragraph starts and
the closing tag (</p>) shows where it ends
o 3. A few tags are called non-container tags. This means, they don't contain any
content within them. Because they do not contain anything within them or because
they do not actually mark anything up, there is no need for them to have closing tag.
Ex:
▪ <br>
▪ <hr>
▪ <img>
o 4. Tags are comprised of elements and attributes. Examples:
▪ Image tag with attribute width:
• <img src="../apple.png" width="500px" height="400px"
alt="Apple's logo">
• The image tag (<img>) is the element and width and src in it are the
attributes of the element.
▪ Anchor tag with hypertext reference:
• <a href="https://www.apple.com/"> Apple Website </a>
▪ Notice that attributes are not included in between the opening and closing
tags. They are rather included with in the opening tag itself only.
<html>
<head>
<title> </title>
</head>
<body>
</body>
</html>
• The first tag in any HTML file is the <html> tag. This tells web browsers that
the document is an HTML file.
• The second tag is a <head> tag. Information between the <head> tags, called
meta information, don't appear in the browser window but are still important.
The most important meta information in the HEAD tag is the <title> tag.
Generally, the title should reflect the contents of the page
• The true content of your web page is included inside the <body> tag
<!DOCTYPE html>
• Structural Tags
▪ <html>
▪ <head>
▪ <body>
▪ <header>
▪ <nav>
▪ <section>
▪ <div>
▪ <h1> to <h6>
▪ <a>
▪ <p>
▪ <br>
▪ <hr>
▪ <footer>
• Metadata Tags
▪ <link>
▪ <style>
▪ <title>
▪ <meta>
• Form Tags
▪ <form>
▪ <input>
▪ <textarea>
▪ <button>
• Formatting Tags
▪ <b>
▪ <center>
▪ <em>
▪ <small>
▪ <strong>
▪ <sup>
• List Tags
▪ <ul>
▪ <ol>
▪ <li>
• Scripting Tags
▪ <script>
• Embedded Content Tags
▪ <img>
▪ <video>
▪ <iframe>
• Commenting and commenting out in HTML
▪ Comments in HTML are used to add text to an HTML document without including
that text in the Web page. HTML comments are not displayed in the browser and
can be used to hide content temporarily. You can add comments to your HTML
source by using the following syntax:
• <!-- Write your comments here -->
• Refer the following link to see a complete list of standard tags belonging to the latest
HTML5. From the list, identify the ones selected above and read about each of them.
Understand what each of them represent when used as tags.
▪ https://www.tutorialrepublic.com/html-reference/html5-tags.php
• For this section, please watch the video demonstrating how Apple.com’s terms and policy is
built using HTML in class