Falytom logoFALYTOM
Games
ToolsUI ComponentsServicesProductsAbout
LoginSign Up
menu
  1. Home
  2. /Web Development
  3. /Html
  4. /First Html Page
Your Progress0%
0 of 76 completed

Topics

Getting Started

  • What is HTML?
  • How the Web Works
  • Setting Up Your Environment
  • Your First HTML Page

HTML Document Structure

  • The DOCTYPE Declaration
  • The HTML Element
  • The Head Section
  • Meta Tags
  • The Body Element
  • HTML Comments

Text and Formatting

  • Headings (h1-h6)
  • Paragraphs
  • Line Breaks and Horizontal Rules
  • Text Formatting (Bold, Italic, etc.)
  • Quotations and Citations
  • Preformatted Text and Code
  • Subscript and Superscript

Links and Navigation

  • Creating Links
  • Absolute vs Relative URLs
  • Link Targets and Attributes
  • Email and Phone Links
  • Internal Page Links

Images and Media

  • Adding Images
  • Image Attributes
  • Image Formats
  • Figure and Figcaption
  • Responsive Images
  • Audio Elements
  • Video Elements
  • Embedding Content

Lists

  • Unordered Lists
  • Ordered Lists
  • Description Lists
  • Nested Lists

Tables

  • Table Basics
  • Table Headers and Footers
  • Spanning Columns and Rows
  • Table Captions
  • Styling Tables

Forms - Part 1 (Basics)

  • Introduction to Forms
  • Text Input Fields
  • Labels and Placeholders
  • Textarea Element
  • Checkboxes
  • Radio Buttons

Forms - Part 2 (Advanced)

  • Select Dropdowns
  • File Upload Inputs
  • HTML5 Input Types
  • Form Validation
  • Form Buttons
  • Fieldsets and Legends
  • Form Accessibility

Semantic HTML

  • What is Semantic HTML?
  • Header and Footer
  • Nav Element
  • Main and Article
  • Section and Aside
  • Div vs Semantic Elements
  • Time and Mark Elements

HTML5 Features

  • HTML5 Overview
  • Canvas Element
  • SVG in HTML
  • Geolocation API
  • Drag and Drop
  • Local Storage
  • Web Workers

Web Accessibility

  • Introduction to Accessibility
  • ARIA Attributes
  • Keyboard Navigation
  • Alt Text Best Practices
  • Color Contrast and Typography
  • Testing for Accessibility

Best Practices & SEO

  • HTML Best Practices
  • SEO Fundamentals
  • Meta Tags for SEO
  • Structured Data

Your First HTML Page

Build a complete HTML page from scratch

It's time to create your first real HTML page so you have an idea of what is to come in the following sessions! In this lesson, we'll build a complete HTML document from scratch and understand every single part of it. By the end, you'll have a working webpage and understand the basic structure that every HTML page follows.

The Basic HTML Structure

Every HTML page follows the same basic structure. Think of it like a house—every house needs a foundation, walls, and a roof. HTML has its own required structure that tells the browser this is an HTML document.

Here's the complete structure of a basic HTML page:

index.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My First HTML Page</title>
  </head>
  <body>
    <h1>Welcome to My Website</h1>
    <p>This is my first paragraph!</p>
  </body>
</html>

Don't worry if this looks confusing right now. We'll break down every single line and explain what it does. By the end of this lesson, it will all make sense!

Creating Your First Page

Let's create this page step by step. Open VS Code and follow along:

  1. Create a new file called index.html
  2. Make sure it's saved in your project folder
  3. We'll now type out the HTML structure line by line

💡 Quick Tip:

In VS Code, you can type ! and press Tab to automatically generate the basic HTML structure. But for learning purposes, type everything out manually at least once—it helps you understand and remember!

Understanding Each Part

Let's go through the HTML structure line by line and understand what each part does.

Line 1: The DOCTYPE Declaration

MARKUP
<!DOCTYPE html>

This is the DOCTYPE declaration. It's always the very first line of an HTML document. Here's what you need to know:

  • It tells the browser that this is an HTML5 document
  • It's not an HTML tag—it's an instruction to the browser
  • You must include it at the top of every HTML page
  • It's not case-sensitive, but lowercase is the convention

In older HTML versions, the DOCTYPE was much longer and complicated. HTML5 simplified it to just <!DOCTYPE html>. Nice and simple!

Line 2: The HTML Element

MARKUP
<html lang="en">

The <html> tag is the root element of your HTML page. Everything else goes inside it. Think of it as the container that holds your entire webpage.

Notice the lang="en" part? This is called an attribute. It tells the browser that the content is in English. This helps with:

  • Search engines understanding your content
  • Screen readers pronouncing text correctly
  • Browsers offering translation services

You can change "en" to other language codes like "es" (Spanish), "fr" (French), or "de" (German).

Lines 3-7: The Head Section

MARKUP
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My First HTML Page</title>
</head>

The <head> section contains metadata—information about your page that doesn't appear on the page itself. It's like the cover and copyright page of a book.

The Character Encoding Meta Tag

MARKUP
<meta charset="UTF-8">

This tells the browser which character set to use. UTF-8 supports all languages and special characters (like émojis! 🎉). Always include this—it prevents weird character display issues.

The Viewport Meta Tag

MARKUP
<meta name="viewport" content="width=device-width, initial-scale=1.0">

This makes your page mobile-friendly. It tells mobile browsers to:

  • Use the device's width as the page width
  • Start at 100% zoom (initial-scale=1.0)

Without this tag, mobile browsers might display your page zoomed out, making text tiny and hard to read. Always include it!

The Title Element

MARKUP
<title>My First HTML Page</title>

The <title> is super important! It:

  • Appears in the browser tab
  • Shows up in search engine results
  • Appears when you bookmark a page
  • Is read by screen readers for accessibility

Every page should have a unique, descriptive title between 50-60 characters. Make it meaningful—"My First HTML Page" is fine for practice, but real websites should use descriptive titles like "About Us - Company Name".

Lines 8-11: The Body Section

MARKUP
<body>
  <h1>Welcome to My Website</h1>
  <p>This is my first paragraph!</p>
</body>

The <body> section contains everything that's visible on your webpage. Everything users see and interact with goes inside the body.

In our example:

  • <h1> creates a large heading (Heading 1)
  • <p> creates a paragraph of text

We'll learn about many more elements in upcoming lessons, but for now, these two are perfect for your first page!

Line 12: Closing the HTML Element

MARKUP
</html>

Every opening tag needs a closing tag! The </html> tag closes the HTML element we opened on line 2. This marks the end of your HTML document.

Your Complete First Page

Now that you understand each part, let's create a slightly more interesting first page:

index.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>John's Personal Website</title>
  </head>
  <body>
    <h1>Welcome to My Personal Website!</h1>
    <p>Hi! My name is John and I'm learning HTML.</p>
    <p>This is my very first webpage. I'm excited to learn more!</p>
    
    <h2>About Me</h2>
    <p>I'm a beginner web developer just starting my journey.</p>
    
    <h2>My Goals</h2>
    <p>I want to learn HTML, CSS, and JavaScript to build amazing websites.</p>
  </body>
</html>

Saving and Viewing Your Page

Step 1: Save Your File

  1. Press Ctrl+S (Windows/Linux) or Cmd+S (Mac)
  2. Make sure your file is named index.html
  3. Check that it's saved in your project folder

Step 2: Open in Browser

There are several ways to view your page:

Method 1: Using Live Server (Recommended)

  1. Right-click anywhere in your HTML file
  2. Select "Open with Live Server"
  3. Your browser opens automatically with your page!

Method 2: Direct File Opening

  1. Find your index.html file in File Explorer/Finder
  2. Double-click it, or right-click and choose "Open with" → Your browser

Method 3: Drag and Drop

  1. Open your web browser
  2. Drag the index.html file into the browser window

What You Should See

When you open your page, you should see:

  • Your title in the browser tab
  • A large heading saying "Welcome to My Personal Website!"
  • Paragraphs of text below the heading
  • Smaller headings for "About Me" and "My Goals"
  • More paragraphs under each heading

🎉 Congratulations!

You've just created your first HTML page! This is a huge milestone. Every website on the internet started with someone writing HTML just like you did.

Understanding Indentation

Notice how the code is indented (moved to the right with spaces)? This is called code formatting and it's very important.

MARKUP
<html>
  <head>
    <title>Example</title>
  </head>
  <body>
    <h1>Heading</h1>
  </body>
</html>

Indentation shows which elements are inside (nested within) other elements:

  • <head> is inside <html>, so it's indented
  • <title> is inside <head>, so it's indented further
  • This makes code easier to read and understand

Most code editors (like VS Code) indent automatically. If your code looks messy, right-click and select "Format Document" (or press Shift+Alt+F / Shift+Option+F).

Important File Naming Rules

When naming HTML files, follow these rules:

  • ✅ Use lowercase letters: index.html
  • ✅ Use hyphens for spaces: about-us.html
  • ✅ No special characters: avoid @ # $ % &
  • ✅ Always use the .html extension
  • ❌ Don't use spaces: my page.html (bad)
  • ❌ Don't use capital letters: AboutUs.html (can cause issues)

Why "index.html" is Special

The file index.html is special because web servers automatically look for it when someone visits your website. If you visit www.example.com, the server automatically loads index.html.

Think of it as the "home page" or "default page" of a website. Most websites have an index.html as their main page.

Try This: Experiment!

Now that you have a working page, try making these changes:

  1. Change the title - Edit the text between <title> tags and save. Watch the browser tab title change!
  2. Add more paragraphs - Add a few more <p> elements with your own text
  3. Change the heading - Modify the text in the <h1> tag
  4. Try a different heading level - HTML has h1, h2, h3, h4, h5, and h6. Try adding <h3> or <h4>

Don't be afraid to experiment! You can't break anything—just undo (Ctrl+Z) if something goes wrong.

Common Beginner Mistakes

Mistake 1: Forgetting Closing Tags

MARKUP
<!-- Wrong -->
<p>This is a paragraph
<p>This is another paragraph

<!-- Correct -->
<p>This is a paragraph</p>
<p>This is another paragraph</p>

Mistake 2: Mixing Up Opening and Closing Tags

MARKUP
<!-- Wrong -->
<body>
  <head>
    <title>Page</title>
  </head>
</body>

<!-- Correct -->
<head>
  <title>Page</title>
</head>
<body>
  <!-- content -->
</body>

Mistake 3: Forgetting the DOCTYPE

MARKUP
<!-- Wrong -->
<html>
  <head>
    <title>Page</title>
  </head>
...

<!-- Correct -->
<!DOCTYPE html>
<html>
  <head>
    <title>Page</title>
  </head>
...

Mistake 4: Wrong Nesting Order

MARKUP
<!-- Wrong - tags overlap -->
<p>This is <strong>important text</p></strong>

<!-- Correct - proper nesting -->
<p>This is <strong>important text</strong></p>

Checking Your Code

You can validate your HTML to check for errors using the W3C HTML Validator:

  1. Visit validator.w3.org
  2. Click "Validate by Direct Input"
  3. Copy and paste your HTML code
  4. Click "Check"

The validator will tell you if there are any errors in your HTML. Don't worry if you see warnings—focus on fixing errors first.

Save This Template

Here's a clean HTML template you can use for future projects. Save this in a file called template.html and copy it whenever you start a new page:

template.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Page Title Here</title>
  </head>
  <body>
    
    <!-- Your content goes here -->
    
  </body>
</html>

Key Takeaways

  • Every HTML page starts with <!DOCTYPE html>
  • The <html> element wraps everything
  • The <head> contains metadata (info about the page)
  • The <body> contains visible content
  • Always include charset and viewport meta tags
  • Every page needs a unique, descriptive title
  • Proper indentation makes code easier to read
  • Always close your tags properly
  • Use lowercase for file names with .html extension
  • index.html is the default home page

What's Next?

You've created your first HTML page and understand its basic structure! In the next lesson, we'll dive deeper into the DOCTYPE declarations. You'll learn why it plays a crucial role in how browsers interpret and display your web pages.

Keep your first HTML page—it's the beginning of your web development journey! You'll look back on it later and be amazed at how much you've learned.

Know someone who'd find this guide helpful? Please share!

Previous
Setting Up Your Environment
Next
The DOCTYPE Declaration

Never Miss a New HTML Tutorial

Join 1,000+ developers learning HTML step-by-step. Get new tutorials, tips, and exclusive resources delivered to your inbox - completely FREE.

You might also like

UI Components

Ready-made components for your projects

Developer Tools

Boost productivity with handy generators

HTML Game

Learn HTML concepts through interactive gameplay

Join Our Web Development Training Program

Master frontend & backend development with hands-on projects.

Menu

Topics

Getting Started

  • What is HTML?
  • How the Web Works
  • Setting Up Your Environment
  • Your First HTML Page

HTML Document Structure

  • The DOCTYPE Declaration
  • The HTML Element
  • The Head Section
  • Meta Tags
  • The Body Element
  • HTML Comments

Text and Formatting

  • Headings (h1-h6)
  • Paragraphs
  • Line Breaks and Horizontal Rules
  • Text Formatting (Bold, Italic, etc.)
  • Quotations and Citations
  • Preformatted Text and Code
  • Subscript and Superscript

Links and Navigation

  • Creating Links
  • Absolute vs Relative URLs
  • Link Targets and Attributes
  • Email and Phone Links
  • Internal Page Links

Images and Media

  • Adding Images
  • Image Attributes
  • Image Formats
  • Figure and Figcaption
  • Responsive Images
  • Audio Elements
  • Video Elements
  • Embedding Content

Lists

  • Unordered Lists
  • Ordered Lists
  • Description Lists
  • Nested Lists

Tables

  • Table Basics
  • Table Headers and Footers
  • Spanning Columns and Rows
  • Table Captions
  • Styling Tables

Forms - Part 1 (Basics)

  • Introduction to Forms
  • Text Input Fields
  • Labels and Placeholders
  • Textarea Element
  • Checkboxes
  • Radio Buttons

Forms - Part 2 (Advanced)

  • Select Dropdowns
  • File Upload Inputs
  • HTML5 Input Types
  • Form Validation
  • Form Buttons
  • Fieldsets and Legends
  • Form Accessibility

Semantic HTML

  • What is Semantic HTML?
  • Header and Footer
  • Nav Element
  • Main and Article
  • Section and Aside
  • Div vs Semantic Elements
  • Time and Mark Elements

HTML5 Features

  • HTML5 Overview
  • Canvas Element
  • SVG in HTML
  • Geolocation API
  • Drag and Drop
  • Local Storage
  • Web Workers

Web Accessibility

  • Introduction to Accessibility
  • ARIA Attributes
  • Keyboard Navigation
  • Alt Text Best Practices
  • Color Contrast and Typography
  • Testing for Accessibility

Best Practices & SEO

  • HTML Best Practices
  • SEO Fundamentals
  • Meta Tags for SEO
  • Structured Data
Falytom logoFALYTOM

Learn technologies like HTML, CSS, JavaScript, React, NodeJS and more through interactive games, tutorials, components and free tools. Transform your businesses with AI chatbots, SEO-optimized websites, and professional development services.

© 2025 Tomilola Group
  • Facebook logo
  • Twitter logo
  • Instagram logo
  • LinkedIn logo
  • GitHub logo
  • YouTube logo