HTML Basic

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 6 Examples + 6 Try It
First steps

Introduction

HTML (HyperText Markup Language) is the foundation of web development. It lets you structure content on the web—headings, paragraphs, links, images, and more.

Understanding HTML is essential for anyone interested in building websites. Every page you visit is built on HTML, even when CSS and JavaScript add style and interactivity on top.

What You’ll Learn

01

Structure

Document layout.

02

Tags

Opening & closing.

03

Attributes

Extra properties.

04

Text

Headings & lists.

05

Media

Links & images.

06

Practice

Build a page.

What Is HTML?

HTML is a markup language used to create web pages. It uses tags to structure text, multimedia, and other elements. HTML files are plain text—browsers read them and render the content for users to see.

Think of HTML as the skeleton of a website. CSS adds visual style; JavaScript adds behavior. But without HTML, there is nothing for those technologies to work with.

💡
Beginner Tip

You do not compile HTML. Save a .html file and open it in any browser. That is your first web page—no server required for local practice.

Basic HTML Document Structure

An HTML document has a predictable layout. Here is the smallest useful HTML5 page:

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</title>
</head>
<body>
  <h1>This is a Heading</h1>
  <p>This is a paragraph.</p>
</body>
</html>
  • <!DOCTYPE html> — Declares the document type as HTML5.
  • <html> — The root element wrapping the entire document. Use lang="en" for accessibility and SEO.
  • <head> — Metadata the browser needs but visitors do not see on the page (title, charset, stylesheets).
  • <body> — Everything visible to users: text, images, links, and more.

The meta charset and viewport lines help browsers display text correctly and scale the page on phones. You will use them on almost every real page.

HTML Elements and Tags

HTML uses tags to define elements. Most elements have an opening tag (e.g., <p>) and a closing tag (e.g., </p>). The content goes between them:

html
<p>Hello, world!</p>

Some elements are void (self-closing)—they have no closing tag and no inner content. Examples include <img>, <br>, and <input>:

html
<br>
<img src="photo.jpg" alt="Description">

In HTML5 you can write void tags as <br> or <br />—both are valid.

Attributes in HTML

Attributes provide extra information about an element. They appear in the opening tag as name="value" pairs.

For example, the src attribute on an <img> tag tells the browser which image file to load:

html
<img src="photo.jpg" alt="A sunset over the ocean">
  • src — Specifies the URL or path of the image.
  • alt — Describes the image for screen readers and when the image cannot load.
  • href — Used on <a> links to set the destination URL.
  • class and id — Hook elements to CSS and JavaScript (you will use these soon).

Explore the full HTML Attributes reference when you need a specific property.

Common HTML Tags

Here are the tags you will use most often as a beginner:

Headings

<h1> through <h6> define heading levels. Use one h1 per page for the main title; h2 and below for subsections:

html
<h1>Main Heading</h1>
<h2>Subheading</h2>

Paragraphs

<p> wraps blocks of text into paragraphs:

html
<p>This is a paragraph of text.</p>

Lists

<ul> creates bullet lists; <ol> creates numbered lists. Each item uses <li>:

html
<ul>
  <li>Item 1</li>
  <li>Item 2</li>
</ul>

Divisions and Spans

<div> is a generic block container—it starts on a new line. <span> is an inline wrapper that flows with text:

html
<div>This is a block of content.</div>
<span>This is inline text.</span>

Later, you will use div and span with CSS classes to lay out and style pages.

Best Practices

✅ Do

  • Use semantic HTML—tags that match meaning (<header>, <main>, <footer>)
  • Validate your HTML with the W3C Markup Validator
  • Add alt text on images and use proper heading order
  • Indent nested tags and add comments for complex sections
  • Include lang, charset, and viewport on every page

❌ Don’t

  • Use multiple h1 tags for styling—use CSS instead
  • Skip closing tags on normal elements like p or li
  • Rely on div for everything when a more specific tag exists
  • Forget alt on informative images
  • Mix presentation into HTML (use CSS for colors and fonts)

Examples Gallery

Six examples from a minimal skeleton to a complete first page. Each includes View Output and Try It Yourself.

📚 Getting Started

Build from a blank page upward.

Example 1 — Minimal HTML5 Skeleton

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 Page</title>
</head>
<body>
  <h1>This is a Heading</h1>
  <p>This is a paragraph.</p>
</body>
</html>
Try It Yourself

How It Works

Every HTML file needs DOCTYPE, html, head, and body. The visible content lives inside body.

Example 2 — Headings h1 and h2

html
<h1>Main Heading</h1>
<h2>Subheading</h2>
Try It Yourself

How It Works

Browsers render h1 larger than h2 by default. Do not pick heading levels for size—use them for document outline.

Example 3 — Paragraph + ul List

html
<h1>My Favorite Things</h1>
<p>Here are a few things I enjoy:</p>
<ul>
  <li>Reading</li>
  <li>Coding</li>
  <li>Walking outdoors</li>
</ul>
Try It Yourself

How It Works

A paragraph introduces the list. Each li becomes one bullet point inside ul.

🖼️ Layout & Media

Group content and add links and images.

Example 4 — div and span

html
<div>
  <p>This is a <span>block of content</span> inside a div.</p>
  <p>Spans wrap <span>inline text</span> without a line break.</p>
</div>
Try It Yourself

How It Works

div groups block-level content; span highlights part of a sentence inline.

Example 6 — My First Web Page

A complete beginner page combining everything from this tutorial:

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 Web Page</title>
</head>
<body>
  <h1>Welcome to My Web Page</h1>
  <p>This is a basic HTML example.</p>

  <h2>Things I Like:</h2>
  <ul>
    <li>Coding</li>
    <li>Web Development</li>
    <li>Coffee</li>
  </ul>

  <p>Visit my <a href="https://example.com">website</a> for more information.</p>
</body>
</html>
Try It Yourself

How It Works

This is a real publishable page: proper head metadata, structured headings, a list, and a link. Save it as index.html and open it in your browser.

Universal Browser Support

Core HTML elements—headings, paragraphs, lists, links, and images—have been supported in every browser for decades. The HTML5 doctype and meta tags work in all modern browsers.

Baseline · Since HTML

Basic HTML elements

Every browser renders standard HTML tags the same way. You do not need polyfills or fallbacks for the fundamentals covered in this tutorial.

100% Core tag support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
Basic HTML elements Universal

Bottom line: Write HTML once; it works in Chrome, Firefox, Safari, Edge, and mobile browsers.

Conclusion

HTML is the foundation of web development. It provides the structure every page needs. Mastering basic tags and attributes is your first step toward becoming a web developer.

Once you are comfortable with HTML, explore HTML Editors to pick a tool, then dive into HTML Tags and HTML Attributes for deeper reference guides. CSS and JavaScript come next for styling and interactivity.

Key Takeaways

🗃 02

head + body

Metadata vs visible.

Structure
🏷️ 03

Tags

Open, close, void.

Syntax
⚙️ 04

Attributes

href, src, alt.

Properties
📝 05

Semantics

Meaningful tags.

Quality
▶️ 06

Practice

Try It editor.

Hands-on

❓ Frequently Asked Questions

HTML (HyperText Markup Language) is the standard language for creating web pages. It uses tags to mark up content—headings, paragraphs, links, images—so browsers know how to display each part of the page.
No. HTML is a markup language—it describes structure and meaning, not logic. Programming languages like JavaScript or Python run instructions; HTML tells the browser what each piece of content is.
No. You can write HTML in any text editor and save the file with a .html extension. Dedicated code editors add syntax highlighting and preview, which makes learning easier—but they are optional.
A tag is the markup syntax, such as <p> or </p>. An element is the complete unit: opening tag, content, and closing tag—or a void tag like <img>. In everyday speech, people often use both words to mean the same thing.
It tells the browser this document follows the HTML5 standard. Always put it on the first line so the browser renders your page in standards mode instead of outdated compatibility quirks.
Save your file as something like index.html, then double-click it or drag it into a browser window. You can also use an editor with live preview, or upload the file to a web host when you are ready to share it online.
Did you know?

The first version of HTML was created by Tim Berners-Lee in 1991 with about 18 tags. Today’s HTML5 standard has roughly 100+ elements, but beginners only need a dozen to build useful pages. The tags in this tutorial cover most everyday websites.

Write your first HTML page

Open the Try It editor, edit the skeleton, and see your page render instantly.

Open Try It editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful