Skip to content

HTML Basics Tutorial for Beginners

Learn the basic building blocks of HTML, including HTML tags, elements, attributes, document structure, VS Code setup, and how to create your first SEO-friendly HTML page.

What Are HTML Basics?

HTML basics are the core concepts every beginner should understand before building web pages. These include HTML tags, elements, attributes, headings, paragraphs, links, images, lists, and the basic structure of an HTML document.

HTML gives content meaning and structure. CSS is used for styling, and JavaScript is used for interactivity, but every website starts with HTML.

Tools Required to Write HTML

You do not need any paid software to learn HTML. A browser and a code editor are enough to create and test your first web page.

  • Code Editor: Visual Studio Code
  • Browser: Chrome, Edge, Firefox, or Safari
  • File Extension: .html

How to Install VS Code for HTML

Visual Studio Code, also called VS Code, is one of the most popular code editors for learning HTML, CSS, JavaScript, React, and modern frontend development.

  1. Go to the official Visual Studio Code website.
  2. Download VS Code for Windows, macOS, or Linux.
  3. Install VS Code using the default setup options.
  4. Open VS Code after installation.
  5. Create a new folder for your HTML practice files.
Recommended VS Code Extensions: Install Live Server, Prettier, and HTML CSS Support to make HTML development easier.

How to Create Your First HTML File in VS Code

After installing VS Code, create your first HTML file and open it in the browser.

  1. Open VS Code.
  2. Create a new folder named html-basics.
  3. Inside that folder, create a file named index.html.
  4. Add the basic HTML code shown below.
  5. Right-click the file and open it with Live Server or open it directly in a browser.
<!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 HTML Basics</h1>
    <p>This is my first HTML page created in VS Code.</p>
  </body>
</html>

Basic HTML Document Structure

Every HTML page follows a basic structure. This structure helps browsers understand the document correctly.

  • <!doctype html>: tells the browser this is an HTML5 document.
  • <html>: root element of the HTML page.
  • <head>: contains metadata, title, and SEO information.
  • <title>: displays the page title in the browser tab.
  • <body>: contains visible page content.

HTML Tags and Elements

HTML uses tags to create elements. An element usually has an opening tag, content, and a closing tag.

<p>This is a paragraph.</p>

In this example, <p> is the opening tag, This is a paragraph. is the content, and </p> is the closing tag.

HTML Attributes

HTML attributes provide extra information about an element. Attributes are written inside the opening tag.

<a href="https://www.example.com">Visit Example</a>

<img src="html-logo.png" alt="HTML logo" />

In the first example, href defines the link destination. In the second example, src defines the image path and alt describes the image for accessibility and SEO.

Common HTML Tags for Beginners

Tag Purpose
<h1> to <h6> Creates headings
<p> Creates paragraphs
<a> Creates links
<img> Displays images
<ul>, <ol>, <li> Creates lists
<div> Creates a generic container
<section> Creates a meaningful page section

HTML Headings and Paragraphs Example

Headings create a clear page hierarchy. Paragraphs are used for readable text content.

<h1>HTML Basics</h1>
<h2>Learning HTML Tags</h2>
<p>HTML tags help structure web page content.</p>

For SEO, use only one main <h1> per page and organize subtopics with <h2> and <h3>.

HTML Basics for SEO

SEO-friendly HTML helps search engines understand your content better. Clean HTML structure can improve crawlability, readability, and page relevance.

  • Use a unique and descriptive <title> tag.
  • Add a helpful meta description for each page.
  • Use heading tags in correct order.
  • Write descriptive image alt text.
  • Use semantic tags like <header>, <main>, and <footer>.
  • Use internal links to connect related tutorial pages.
<head>
  <title>HTML Basics Tutorial for Beginners</title>
  <meta
    name="description"
    content="Learn HTML basics with examples, tags, elements, attributes, and beginner best practices."
  />
</head>

HTML Basics for Accessibility

Accessible HTML helps people using screen readers, keyboards, and assistive tools. Good accessibility also improves the overall quality of your website.

  • Use semantic tags instead of only <div>.
  • Add alt text for meaningful images.
  • Use labels for form fields.
  • Keep heading order logical.
  • Use meaningful button and link text.
<label for="email">Email Address</label>
<input id="email" type="email" name="email" />

Beginner HTML Practice Project

Create a simple profile page using the HTML basics you learned in this lesson.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>My Profile Page</title>
  </head>
  <body>
    <header>
      <h1>My Profile</h1>
    </header>

    <main>
      <section>
        <h2>About Me</h2>
        <p>I am learning HTML basics.</p>
      </section>

      <section>
        <h2>My Skills</h2>
        <ul>
          <li>HTML</li>
          <li>CSS</li>
          <li>JavaScript</li>
        </ul>
      </section>
    </main>

    <footer>
      <p>Created by a beginner HTML learner.</p>
    </footer>
  </body>
</html>

Common HTML Basics Mistakes

  • Forgetting to save the file with .html extension.
  • Missing closing tags.
  • Using headings only for styling instead of structure.
  • Using empty or unclear alt text for important images.
  • Skipping the viewport meta tag.
  • Writing all content inside <div> tags instead of semantic tags.

Key Takeaways

  • HTML basics include tags, elements, attributes, and document structure.
  • VS Code is a beginner-friendly editor for writing HTML.
  • Every HTML page should include doctype, html, head, title, and body.
  • Semantic HTML improves SEO, accessibility, and readability.
  • Practice by creating simple pages like profile pages, landing pages, and blog layouts.

Pro Tip

Use VS Code with the Live Server extension so you can instantly preview HTML changes in your browser.