HTML Basic Examples
> A W3Schools-style first examples chapter: understand the code, try it, inspect the browser result, and practise common HTML elements.
**Cyber Code Academy · HTML Tutorial · Beginner**
## What will you learn?
In this chapter, you will create a complete HTML document and learn common examples for headings, paragraphs, links, images, lists, and tables. These examples are small building blocks used throughout frontend development.
## 1. A basic HTML document
Every HTML page should declare its document type and contain a root html element, a head section, and a body section.
### Example
“`html
Hello, World!
This is my first HTML page.
“`
### Explanation
The doctype declaration selects standards mode. The head contains the title and metadata. The body contains the heading and paragraph that visitors see.
### Expected output
The browser tab displays **My First HTML Page**. The page displays a large “Hello, World!” heading followed by a paragraph.
## 2. HTML headings
HTML has six heading levels: h1, h2, h3, h4, h5, and h6. They express the structure of the content.
### Example
“`html
Frontend Development
HTML
HTML Basics
CSS
CSS Selectors
“`
### Explanation
The h1 is the main heading in this example. h2 introduces major sections, and h3 introduces subsections. Do not skip heading levels just to obtain a particular font size. CSS should control visual size.
### Expected output
The browser displays the headings in descending default size. The visual hierarchy follows the document outline you wrote.
## 3. HTML paragraphs
The p element represents a paragraph. Browsers normally add spacing before and after paragraphs.
### Example
“`html
HTML structures the content of a web page.
CSS controls the visual presentation of that content.
JavaScript adds behaviour and interactivity.
“`
### Expected output
Three separate text blocks are displayed with default paragraph spacing.
## 4. HTML links
The a element creates a hyperlink. The href attribute supplies the destination.
### Example
“`html
Visit the W3C website
“`
### Open a new tab
“`html
Open W3C in a new tab
“`
Use descriptive link text. Avoid vague labels such as “Click here” when the destination can be described.
### Expected output
The link text appears clickable and normally underlined. Selecting it navigates to the destination.
## 5. HTML images
The img element embeds an image. It is a void element, so it does not need a closing tag.
### Example
“`html

“`
### Explanation
– src points to the image resource.
– alt supplies a text alternative.
– width and height provide intrinsic dimensions and help the browser reserve space.
The file must exist at the specified path. Alternative text should describe the image’s purpose in context. Use an empty alt value only when the image is decorative.
## 6. HTML lists
### Unordered list
“`html
- HTML
- CSS
- JavaScript
“`
### Ordered list
“`html
- Create a file.
- Write HTML.
- Open it in a browser.
“`
Use ul when the order does not matter and ol when sequence is meaningful. Each list item belongs inside the list.
## 7. HTML tables
Tables represent data arranged in rows and columns. Do not use them to position normal page layout.
### Example
“`html
| Course | Duration |
|---|---|
| HTML | 2 weeks |
| CSS | 3 weeks |
“`
The caption describes the table. Header cells identify what each column represents. The browser displays rows and columns; CSS can later improve their appearance.
## 8. Combine the examples
Try a complete small page:
“`html
Learn Web Development
Start with HTML, then learn CSS and JavaScript.
Topics
- HTML
- CSS
- JavaScript
“`
## Common mistakes
– Forgetting the doctype declaration.
– Placing visible content inside head rather than body.
– Forgetting quotation marks around attribute values.
– Using an image path that does not exist.
– Forgetting alternative text.
– Using a table for page layout.
– Selecting headings only for their default font size.
## Practice exercises
1. Create a page with one h1, two h2 headings, and three paragraphs.
2. Add an external link and explain its href destination.
3. Add one local image with useful alternative text.
4. Create an ordered list of five steps.
5. Create a course table with three rows.
6. Combine at least four element types into one complete page.
## Quick revision
– head contains metadata; body contains page content.
– Headings range from h1 to h6.
– a creates links, img embeds images, and li represents list items.
– Tables should have meaningful header cells.
– HTML describes structure; CSS will be used to style it.
**Next chapter:** Continue to HTML Elements and Attributes.
Want to learn this professionally?
Explore practical IT training at Cyber Code Academy.
View Academy Courses