HTML Tutorial

Learn HTML step by step with easy examples

What is HTML?

HTML stands for HyperText Markup Language. It's the standard language used to create web pages. Think of HTML as the skeleton of a website - it provides the basic structure and content.

HTML uses "tags" to mark up content. Tags are keywords surrounded by angle brackets:

<tagname>content goes here</tagname>

Basic HTML Structure

Every HTML document has the same basic structure. Let's start with a simple example:

html
1
2
3
4 My First Web Page
5
6
7

Hello World!

8

This is my first paragraph.

9
10

Let's break this down:

  • <!DOCTYPE html>Tells the browser this is an HTML5 document
  • <html>The root element that contains all other elements
  • <head>Contains information about the page (not visible to users)
  • <title>Sets the page title (shown in browser tab)
  • <body>Contains all the visible content of the page

Headings

HTML has 6 levels of headings, from h1 (largest) to h6 (smallest). Use them to organize your content:

html
1

This is a Main Heading

2

This is a Section Heading

3

This is a Subsection Heading

4

This is a Smaller Heading

5
This is an Even Smaller Heading
6
This is the Smallest Heading

Tip:

Use headings in order (h1, then h2, then h3, etc.). Don't skip levels. This helps screen readers and search engines understand your content structure.

Paragraphs and Text Formatting

Learn how to add and format text on your web pages:

Basic Text
Paragraphs and line breaks
html
1

This is a paragraph. It can contain multiple sentences and will wrap to the next line automatically.

2 
3

This is another paragraph. Each paragraph tag creates a new block of text.

4 
5

You can add a line break

6anywhere in your text using the br tag.

Text Formatting
Make text bold, italic, and more
html
1

This text is bold and important.

2 
3

This text is emphasized (italic).

4 
5

This is highlighted text.

6 
7

This is smaller text.

8 
9

This is deleted text and inserted text.

Links

Links connect web pages together. The anchor tag <a> creates links:

Link Attributes Explained:

  • href - The destination URL or file
  • target="_blank" - Opens link in a new tab
  • title - Tooltip text when hovering over the link

Images

Add images to your web pages with the img tag:

html
1
2text-[#9cdcfe]">src="photo.jpg" text-[#9cdcfe]">alt="A beautiful sunset">
3 
4
5text-[#9cdcfe]">src="logo.png" text-[#9cdcfe]">alt="Company Logo" text-[#9cdcfe]">width="200" text-[#9cdcfe]">height="100">
6 
7
8text-[#9cdcfe]">src="banner.jpg" text-[#9cdcfe]">alt="Website Banner" text-[#9cdcfe]">style="max-width: 100%; height: auto;">
9 
10

Important:

Always include the alt attribute. It describes the image for people who can't see it and helps with accessibility.

Lists

Create ordered (numbered) and unordered (bulleted) lists:

Unordered Lists
Lists with bullet points
html
1

My Favorite Foods:

2
    3
  • Pizza
  • 4
  • Ice Cream
  • 5
  • Chocolate
  • 6
  • Pasta
  • 7
    Ordered Lists
    Numbered lists
    html
    1

    Steps to Make Coffee:

    2
      3
    1. Boil water
    2. 4
    3. Add coffee grounds
    4. 5
    5. Pour hot water
    6. 6
    7. Wait 4 minutes
    8. 7
    9. Enjoy!
    10. 8

      Nested Lists

      You can put lists inside other lists:

      html
      1

      Web Development Skills:

      2
        3
      • Frontend
      • 4
          5
        • HTML
        • 6
        • CSS
        • 7
        • JavaScript
        • 8
          9
          10
        • Backend
        • 11
            12
          • Node.js
          • 13
          • Python
          • 14
          • PHP
          • 15
            16
            17

            Tables

            Tables display data in rows and columns. Here's how to create a simple table:

            html
            1
            2
            3
            4
            5
            6
            7
            8
            9
            10
            11
            12
            13
            14
            15
            16
            17
            18
            19
            20
            21
            22
            23
            24
            25
            26
            NameAgeCity
            John25New York
            Sarah30London
            Mike28Tokyo

            Table Elements Explained:

            • <table> - Creates the table
            • <thead> - Table header section
            • <tbody> - Table body section
            • <tr> - Table row
            • <th> - Table header cell
            • <td> - Table data cell

            Forms

            Forms collect information from users. Here's a simple contact form:

            html
            1
            2

            Contact Us

            3
            4 ">for="name">Your Name:
            5 text-[#9cdcfe]">type="text" text-[#9cdcfe]">id="name" text-[#9cdcfe]">name="name" required>
            6
            7 ">for="email">Your Email:
            8 text-[#9cdcfe]">type="email" text-[#9cdcfe]">id="email" text-[#9cdcfe]">name="email" required>
            9
            10 ">for="message">Your Message:
            11
            12
            13 ">for="newsletter">
            14 text-[#9cdcfe]">type="checkbox" text-[#9cdcfe]">id="newsletter" text-[#9cdcfe]">name="newsletter">
            15 Subscribe to newsletter
            16
            17
            18
            19

            Common Input Types:

            type="text" - Regular text input

            type="email" - Email address

            type="password" - Password (hidden text)

            type="number" - Numbers only

            type="checkbox" - Checkboxes

            type="radio" - Radio buttons

            type="date" - Date picker

            type="file" - File upload

            Practice Exercise

            Try creating a simple "About Me" page using what you've learned. Include:

            • A main heading with your name
            • A paragraph about yourself
            • A list of your hobbies
            • A link to your favorite website
            • An image (you can use a placeholder)

            Use our code editor to practice! Start with the basic HTML structure and add your content.