HTML structure and common tags

Foundation

HTML marks content with paired tags. Skeleton: DOCTYPE, html, head (for the browser), body (for visitors). Common: h1-h6 headings, p paragraphs, ul/ol+li lists, a links, img images; semantic tags header/nav/main/footer let machines read the structure too.

For:Secondary 3 Information & Communication Technology · Unit:Web design · Lesson 8 of 13 in the learning path

After this lesson, you can:
  • HTML is a markup language: paired tags wrap content; last opened, first closed.
  • The skeleton's four pieces: DOCTYPE, html, head (for the browser), body (for visitors).
  • Everyday tags: h1-h6 headings, p paragraphs, ul/ol with li lists, a links, img images.
文體:編程教學課有聲朗讀

文體小知識:編程教學課每個概念都配一段可以親手試的代碼例子,照住輸入、改一改,最快學會。

資訊及通訊科技Information & Communication Technology

§Text Passage

1The skeleton of every web page is HTML (HyperText Markup Language): not a programming language but a markup language — pairs of tags tell the browser 'this is a heading, this is a paragraph'. Nearly all tags come in pairs: in <p>Hello!</p>, <p> opens and </p> closes (with a slash), and the text between is the content.

2Every HTML file shares one skeleton: <!DOCTYPE html> declares HTML5; <html> wraps everything; <head> holds information for the browser (the page title, the text encoding) which never shows on the page; <body> holds everything a visitor sees. Save the code as index.html and open it in a browser to see the page — that is how web writing starts.

3The most used tags come in a few families: headings <h1> to <h6> (a page normally has one <h1>); paragraphs <p>; lists, <ul> with <li> (bulleted) or <ol> with <li> (numbered); hyperlinks <a href="url">text</a>; images <img src="photo.jpg" alt="caption"> (a single tag, no closing). Extra details attached to a tag — href, src, alt — are called attributes.

4Newer HTML encourages semantic tags: <header> for the page top, <nav> for the menu, <main> for the chief content, <footer> for the bottom. They look like <div> but state what each part is for, letting search engines and screen readers (software reading pages aloud for blind users) understand the structure — a page is not only drawn for people, it also speaks to machines.

1Summary 重點摘要

HTML marks content with paired tags. Skeleton: DOCTYPE, html, head (for the browser), body (for visitors). Common: h1-h6 headings, p paragraphs, ul/ol+li lists, a links, img images; semantic tags header/nav/main/footer let machines read the structure too.

2Vocabulary cards Vocabulary

H
HTML超文字標記語言

The markup language behind web pages, using tags to describe content's structure and meaning.

T
Tag標籤

A marker in angle brackets, mostly in pairs: opening <p>, closing </p>.

E
Element元素

The whole of an opening tag, its content and the closing tag — <p>Hello</p> is one paragraph element.

A
Attribute屬性

Extra information inside an opening tag, e.g. href on <a href="...">, src and alt on <img>.

h
head / body頁首區/內容區

head holds information for the browser (title, encoding); body holds everything shown to visitors.

H
Hyperlink <a>超連結標籤

The link tag whose href gives the destination, e.g. <a href="https://...">go</a>.

I
Image <img>圖片標籤

A single tag: src names the image file, alt carries the description text.

S
Semantic tags語意化標籤

Structure tags declaring purpose: header, nav, main, footer.

N
Nested structure巢狀結構

Tags inside tags, layer by layer; the first opened closes last, never crossing.

3Step by step Steps

  1. The smallest page skeletonEvery page file shares one skeleton: <!DOCTYPE html> declares an HTML5 document; <html> wraps everything; <head> holds browser-facing information such as <title>My page</title>, which shows on the browser tab rather than on the page; <body> holds everything a visitor sees. Save the skeleton as index.html and open it in a browser: the tab shows 'My page' and the page shows 'Hello!'. The skeleton is every page's foundation and must be memorised exactly.
  2. Headings and paragraphs<h1> to <h6> are six heading levels, h1 the largest and h6 the smallest; a page normally uses one h1 as the main title, with h2 and h3 subdividing the sections level by level — never skipping. <p> wraps a paragraph with automatic spacing before and after, as in writing <h1>Class 3A home</h1> and <p>My first web page.</p> inside body. Heading levels do more than set font size: they declare the document's structure to search engines and screen readers, and misused headings leave blind visitors lost.
  3. Two kinds of listsTwo list kinds exist. The unordered list ul with li shows bullets: <ul><li>football</li><li>chess</li></ul>; the ordered list ol numbers itself 1. 2.: <ol><li>boot up</li><li>log in</li></ol>. The choosing standard is whether order carries meaning: a hobby list has no order and takes ul; procedure steps are order-critical and take ol. Every li must sit inside a ul or ol — placing li directly in body is invalid, and although the browser may still display it, the structure is already wrong.
  4. Links and imagesLinks use the a tag: <a href="https://www.labzstudy.com">Visit LabzStudy</a>, with href holding the destination and the text between being the clickable part; for another page on your own site write a relative path like <a href="about.html">About us</a>. Images use the single img tag: <img src="images/campus.jpg" alt="A panorama of the campus">, where src points to the image location and alt is the description shown when the image cannot be seen; screen readers for the visually impaired speak the alt text, so it must never be left empty.
  5. Semantic tagsSemantic tags state each part's purpose: <header> for the page top, <nav> for the navigation menu, <main> for the chief content, <footer> for the bottom. Inside body place them in order: <header>Class 3A site</header>, <nav>Home | Gallery</nav>, <main>Welcome to our class site</main>, <footer>© 2026 Class 3A</footer>. They look like div but tell machines what each region is, letting search engines and screen readers understand the structure. A page is not only drawn for people — it also speaks to machines.
  6. The nesting rule: last opened, first closedTag nesting obeys 'last opened, first closed': for bold inside a paragraph write <p>This is <strong>key</strong> content</p> — strong opens inside p and must close before p closes. The crossed form <p>...<strong>...</p></strong> may still render in lenient browsers, but the structure is wrong, the layout may fall apart, and the page's DOM tree becomes illegal. Check from the inside out: the tag opened last must close first, like packing small cases before big ones and unpacking small ones first.
  7. Attributes and how to learnAttributes are extra information inside the opening tag, written name='value': href, src, alt, class and id are all attributes, and one tag may carry several, separated by spaces. The most effective way to learn HTML is write-and-look: create index.html in a text editor, save after every change and refresh the browser to see the effect at once. HTML rarely reports errors — it quietly misbehaves instead — so build the habit of small edits followed by immediate checks, and mistakes will never pile up.

4Diagrams Diagrams

HTML:網頁嘅骨架 HTML structure<html><head> <title>我嘅網頁</title> </head><body><h1>歡迎</h1> <p>呢度係內容。</p>標籤成對出現:<p> 開,</p> 關——內容夾在中間<h1>~<h6>標題,數字越細越大<p>一段文字<img> <a>圖片・連結分工:HTML 管「有乜內容」,CSS 管「點樣美化」——搭檔關係
Fig. 1: HTML structure

5Worked example Example

Example: build a small 'about me' page with a page title, one main heading, a self-introduction paragraph, a hobby list and one external link.

  1. Write the skeleton: <!DOCTYPE html> <html> <head><title>About me</title></head> <body>...</body> </html> — the title shows on the browser tab.
  2. Add heading and paragraph: inside body write <h1>I am Mary</h1> <p>A student from 3A who loves sports and computing.</p>.
  3. Add the hobby list: <ul><li>basketball</li><li>coding in Python</li><li>photography</li></ul> — three items, bullets automatic.
  4. Add the link and close: <a href="https://www.labzstudy.com">My favourite study site</a>, then finish with </body> </html>.
  5. Answer: The finished page is the skeleton plus four parts: title, h1+p, a ul list, an a link — saved as an .html file and opened in any browser.

6Common mistakes Mistakes

✗ Stopping at <p>I love HTML without the closing tag.
✓ Nearly all tags pair up: missing </p> leaves the browser guessing, and the layout falls apart; open it, close it.
✗ Putting content inside head and expecting it to show.
✓ head is for the browser (title, encoding) and never displays; all visible content belongs in body.
✗ Leaving an image's alt empty because the picture is there anyway.
✓ alt is the accessibility key: when an image fails to load or a blind user's screen reader passes by, alt is the only description.
✗ Dropping href from a link tag and expecting the text to stay clickable.
✓ An <a> without href is not a link and never responds; href is the destination and is required.
✗ Making text big by wrapping everything in h1.
✓ Heading tags carry structure (h1 most important, one per page), not font size; size belongs to CSS.

7Quick check Quick check

Q1Where does visible page content go? A. <head> B. <body> C. <title>

Q2How many <h1> should a page normally have?

Q3Write the link tag going to about.html with the text 'About us'.

Q4What is the img tag's alt attribute for?

Q5What are <nav>, <main> and <footer> collectively called, and why use them?

8Recap Recap

  • HTML is a markup language: paired tags wrap content; last opened, first closed.
  • The skeleton's four pieces: DOCTYPE, html, head (for the browser), body (for visitors).
  • Everyday tags: h1-h6 headings, p paragraphs, ul/ol with li lists, a links, img images.
  • Attributes sit in the opening tag: href for destinations, src for image files, alt as the required description.
  • Semantic tags header/nav/main/footer let machines read the page structure too.

Other subjects in this grade

Same subject, other grades