Learn the basic structure that forms the skeleton of an HTML document and the tags you will use most often.
1. What is HTML?
HTML (HyperText Markup Language) is the language that describes the structure and content of a web page. It is not a programming language but a markup language, and it uses tags to express the structure of a document.
<tag-name>content</tag-name>
- An opening tag (
<tag>) and a closing tag (</tag>) come in pairs. - Some tags are used on their own without a closing tag (for example:
<br>,<img>,<input>)
2. The DOCTYPE Declaration
<!DOCTYPE html>
- It must always be written on the first line of an HTML document.
- It is a declaration that tells the browser "this document is in HTML5 format."
<!DOCTYPE html>is the HTML5 standard declaration and is not case sensitive.
3. The Basic Structure of an HTML Document
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page title</title>
</head>
<body>
<!-- Write the content that actually appears on screen here -->
<h1>Hello!</h1>
<p>This is my first HTML document.</p>
</body>
</html>
| Tag | Role |
|---|---|
<html lang="en"> |
The top-level tag that wraps the whole document. The lang attribute specifies the language |
<head> |
The area that holds document information that is not shown in the browser |
<body> |
The content actually displayed on the browser screen |
4. Meta Tags
Meta tags are written inside <head> and provide extra information about the document.
<!-- Character encoding: set to UTF-8 so that text does not break -->
<meta charset="UTF-8">
<!-- Viewport setting for responsive web pages -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Page description for search engines -->
<meta name="description" content="This page is an example page for learning the basics of HTML.">
<!-- Keywords for search engines -->
<meta name="keywords" content="HTML, web, basics, lesson">
<!-- Author information -->
<meta name="author" content="John Doe">
<!-- Title shown in the browser tab -->
<title>My First HTML Page</title>
5. Heading Tags (h1 ~ h6)
HTML has six levels of heading tags. The larger the number, the smaller the text.
<h1>Level 1 heading - the largest and most important heading (one per page recommended)</h1>
<h2>Level 2 heading - the title of a main section</h2>
<h3>Level 3 heading - a subheading</h3>
<h4>Level 4 heading</h4>
<h5>Level 5 heading</h5>
<h6>Level 6 heading - the smallest heading</h6>
Caution: Heading tags are used to express the hierarchy of the document, not to adjust font size. Adjust font size with CSS.
6. Paragraph Tag (p)
<p>This is the first paragraph. Paragraphs automatically get space above and below.</p>
<p>This is the second paragraph. Even if you add line breaks inside a p tag, the browser treats them as a single space.</p>
7. div and span
| Tag | Characteristic | Use |
|---|---|---|
<div> |
A block-level element (takes up an entire line) | Grouping large areas |
<span> |
An inline element (takes up only as much as its content) | Grouping part of a text |
<!-- div: block level - a line break appears automatically -->
<div>This area takes up a whole line.</div>
<div>The next div starts on a new line.</div>
<!-- span: inline - used within the flow of text -->
<p>In this sentence, only <span>this part</span> can be styled separately.</p>
8. List Tags
Unordered List (ul - Unordered List)
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Strawberry</li>
</ul>
Result:
- Apple
- Banana
- Strawberry
Ordered List (ol - Ordered List)
<ol>
<li>Prepare the ingredients</li>
<li>Boil the water</li>
<li>Add the ingredients</li>
<li>Done in 5 minutes!</li>
</ol>
Result:
- Prepare the ingredients
- Boil the water
- Add the ingredients
- Done in 5 minutes!
Nested Lists
<ul>
<li>Fruit
<ul>
<li>Apple</li>
<li>Banana</li>
</ul>
</li>
<li>Vegetables
<ul>
<li>Carrot</li>
<li>Spinach</li>
</ul>
</li>
</ul>
9. Comments
<!-- This is a comment. It is not shown on the browser screen. -->
<!-- Used to explain code or to temporarily disable code -->
Summary
| Tag | Description |
|---|---|
<!DOCTYPE html> |
HTML5 document declaration |
<html> |
The top-level element of the document |
<head> |
Document meta information |
<body> |
Content displayed on screen |
<meta> |
Extra document information |
<title> |
Browser tab title |
<h1>~<h6> |
Headings (hierarchy) |
<p> |
Paragraph |
<div> |
Block-level container |
<span> |
Inline container |
<ul> |
Unordered list |
<ol> |
Ordered list |
<li> |
List item |
Next Steps
- View the example file - A self-introduction page example
- Check the assignment - Build a page introducing your family
- Next lesson: Text Elements