how to html

How to HTML: A Simple Beginner Guide

Every website you have ever visited is built on HTML. Search results, social feeds, online stores, and news pages all start as plain text files written in HTML, and a browser turns that text into the page you see. Learning how to HTML is the simplest possible first step into web development, because you need no software to install, no account to create, and no programming experience. At CPN Tech, we explain technology simply, and this guide follows that same approach from the first tag to your first finished page.

How to HTML means writing a plain text file with markup tags that tell a browser how to structure content. You open a text editor, type a few tags such as headings, paragraphs, links, and images, save the file with a .html extension, and open it in any browser. This guide shows you each step in order, explains the 20 tags that cover most real pages, and ends with a complete page you can build yourself.

Key Takeaways

  • HTML stands for HyperText Markup Language, and it gives a web page structure, not style or behavior.
  • You need only a text editor and a browser to start; nothing to install and nothing to pay for.
  • About 20 tags cover 90 percent of real web pages, so beginners can learn the useful core in days.
  • Every HTML page follows the same skeleton: doctype, html, head, and body.
  • Semantic tags such as header, nav, main, and footer make pages easier to read, search, and use with assistive technology.
  • The W3C Markup Validation Service catches the small mistakes that break pages, so check your work early.

Table of Contents

  • What Is HTML?
  • What Do You Need to Start Writing HTML?
  • How Do You Write Your First HTML Page?
  • What Are HTML Tags, Elements, and Attributes?
  • Which HTML Tags Should Beginners Learn First?
  • How Do You Add Links, Images, and Lists to a Page?
  • How Do You Build a Complete Web Page with HTML?
  • What Is Semantic HTML and Why Does It Matter?
  • How Do You Check and Fix Your HTML?
  • What Should You Learn After HTML?
  • Frequently Asked Questions
  • Conclusion

What Is HTML?

HTML stands for HyperText Markup Language. It is the standard language that describes the structure of every web page. The word HyperText refers to links that connect one page to another, and Markup means the tags you add to plain text to give it meaning. HTML is not a programming language, because it has no logic, loops, or calculations. It simply labels content so a browser knows what each part is: this is a heading, this is a paragraph, this is a link, this is an image.

HTML was created by Tim Berners-Lee, the inventor of the World Wide Web, and the first version appeared in 1993. Since then the language has grown through versions, and the current standard is the HTML Living Standard, maintained by the Web Hypertext Application Technology Working Group (WHATWG) and updated continuously rather than released in numbered versions. Most people still call the current version HTML5, and that name is fine in everyday conversation.

Think of a web page as a house. HTML is the frame and the room plan: it decides where the walls, doors, and windows go. CSS is the paint and decoration, and JavaScript is the wiring and plumbing that makes things move and respond. You cannot build the house without the frame, which is why HTML comes first in every web development path. If you want the full picture of how the three fit together, read our guide to HTML CSS and JavaScript.

How HTML works in a browser

When you open a web page, the browser downloads an HTML file and reads it from top to bottom. Each tag tells the browser how to display the content inside it. A heading tag makes text large and bold, a paragraph tag adds space around a block of text, and an image tag fetches a picture file and shows it. The browser then builds a tree-like structure called the Document Object Model, or DOM, which represents every element on the page. CSS styles that tree, and JavaScript can change it, but HTML is the tree itself.

HTML is for structure, not appearance

Beginners often try to use HTML to control colors, fonts, and layout. That is CSS territory. HTML answers questions such as: Is this text a main heading or a subheading? Is this a list or a paragraph? Is this image decorative or informative? Keeping that separation makes your pages cleaner, easier to maintain, and easier for search engines and screen readers to understand.

What Do You Need to Start Writing HTML?

You need two things: a text editor and a web browser. You already have both. Any computer ships with a simple editor such as Notepad on Windows or TextEdit on Mac, and any modern browser such as Chrome, Firefox, Edge, or Safari can open an HTML file. No server, no hosting, and no paid software is required for learning.

Choose a text editor

A plain text editor is best for learning, because it shows you exactly what you type with no hidden formatting. Word processors such as Microsoft Word or Google Docs are a poor choice, because they add invisible formatting that breaks HTML. Good free options include Visual Studio Code, Notepad++, and Sublime Text. Visual Studio Code is the most popular choice among beginners because it highlights tags in color, closes brackets for you, and suggests tag names as you type. If you are just starting today, install Visual Studio Code and use it for every example in this guide.

Choose a browser and learn two shortcuts

Chrome, Firefox, and Edge all work well for learning HTML. Pick the one you already use every day, because familiarity saves time. Two shortcuts will help you constantly. Press Ctrl plus U (or Command plus Option plus U on Mac) to view the source of any page, which shows you the real HTML behind a live website. Press F12 to open Developer Tools, which lets you inspect any element, see its HTML, and test small changes without saving a file. Both shortcuts turn the whole web into a free textbook.

What you do not need yet

You do not need a web server, a domain name, or web hosting to learn HTML. You open files directly from your computer, and the browser renders them exactly as it would render a file from a server. You do not need to learn CSS or JavaScript first. You do not need to memorize all 100-plus HTML elements, because about 20 of them do almost all the work on real pages, and this guide lists them in one table below.

How Do You Write Your First HTML Page?

Writing your first page takes five minutes and four steps. You will create a file, type the basic skeleton, add a heading and a paragraph, save it, and open it in your browser. If you can type and save a file, you can do this.

Step 1: Create the file

Open your text editor and create a new file. Save it immediately with the name index.html, and save it in a folder you can find easily, such as a folder called my-first-page on your Desktop. The .html extension is the important part: it tells the editor and the browser that the file contains HTML. Do not save it as index.html.txt, which happens when Windows hides file extensions. If your editor asks about the file type, choose HTML or All Files before saving.

Step 2: Type the basic skeleton

Every HTML page uses the same skeleton. Type it exactly as shown, or copy it and study each line afterward:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>My First Page</title>
</head>
<body>
  <h1>Hello, World!</h1>
  <p>This is my first web page.</p>
</body>
</html>

Step 3: Understand each line

The first line, <!DOCTYPE html>, is a declaration that tells the browser this document uses modern HTML. The <html lang="en"> tag is the root element that wraps everything else, and lang=”en” tells the browser and screen readers that the page is in English. The <head> section holds information about the page that visitors do not see, such as the character encoding and the page title. The <meta charset="UTF-8"> line sets the character encoding so special characters display correctly. The <title> text appears in the browser tab and in search results. The <body> section holds everything visible on the page: in this example, one heading and one paragraph.

Step 4: Save and open the page

Save the file, then double-click it or drag it into your browser window. You will see a large heading that reads Hello, World! and a paragraph below it. That is a real web page, running on your own computer. Change the heading text, save again, and refresh the browser to see the change instantly. That save-and-refresh loop is the core rhythm of web development, and you will repeat it hundreds of times as you learn. Our step-by-step guide to How Do I Create an HTML File covers the same process in even more detail, including the file extension mistakes that trap most beginners.

What Are HTML Tags, Elements, and Attributes?

how to html

Tags, elements, and attributes are the three words beginners confuse most, so learn them clearly now and the rest of HTML becomes much easier.

Tags

A tag is a keyword wrapped in angle brackets. An opening tag such as <p> marks where something begins, and a closing tag such as </p> marks where it ends. The closing tag always has a forward slash before the name. Most tags come in pairs, and the content sits between them.

Elements

An element is the complete unit: the opening tag, the content, and the closing tag together. The element <p>This is a paragraph.</p> is a paragraph element. When people say tag, they often mean element, and in casual conversation that is fine. In precise terms, the tag is the bracketed label and the element is the whole package.

Attributes

An attribute adds extra information to an element. Attributes always appear inside the opening tag, written as a name, an equals sign, and a value in quotation marks. In the element <a href="https://www.cpntech.com">Visit CPN Tech</a>, href is the attribute, and its value is the address the link points to. In <img src="photo.jpg" alt="A sunset over the sea">, src tells the browser where the image file is, and alt provides a text description of the image. Always use double quotes around attribute values, because it keeps your code consistent and avoids errors when a value contains spaces.

Nesting and empty elements

Elements can sit inside other elements, which is called nesting. The element that opens first must close last, like closing boxes inside boxes in the right order. This is correct nesting:

<p>This is <strong>important</strong> text.</p>

This is broken nesting, and browsers will try to guess what you meant:

<p>This is <strong>important</p></strong>

Some elements have no content and no closing tag. These are called empty elements, or void elements. The line break <br>, the horizontal rule <hr>, and the image <img> are the most common. An image element carries all its information in attributes, so it never needs a closing tag.

Block and inline elements

Elements fall into two display groups. Block-level elements start on a new line and take up the full width available. Headings, paragraphs, lists, and divisions are block elements. Inline elements stay inside the current line and take up only as much width as their content needs. Links, bold text, and images are inline elements. You do not need to memorize which is which yet, but knowing the difference explains why a paragraph always starts a new line while a link sits inside a sentence.

Which HTML Tags Should Beginners Learn First?

HTML has more than 100 elements, but about 20 of them cover 90 percent of real pages. Learn these first, grouped by the job each one does, and you can build almost any basic page.

Tag Job Example use
<!DOCTYPE html> Declares the document type First line of every page
<html> Root element that wraps the page Wraps head and body
<head> Holds page information Title, meta tags, links to CSS
<title> Sets the browser tab and search title Inside head
<meta> Sets page data such as encoding Character set, description
<body> Holds all visible content Everything the visitor sees
<h1> to <h6> Headings, from most to least important Page title, section titles
<p> Paragraph of text Body copy
<a> Link to another page or location Navigation, references
<img> Embeds an image Photos, illustrations, logos
<ul> Unordered (bulleted) list Feature lists
<ol> Ordered (numbered) list Steps, rankings
<li> One item inside a list Each bullet or number
<div> Generic container for grouping Layout sections
<span> Generic inline container Styling a few words
<table> Table of rows and columns Data, prices, schedules
<tr>, <td>, <th> Table row, cell, header cell Inside a table
<form> Collects user input Contact and signup forms
<input> A field inside a form Text box, checkbox, button
<button> A clickable button Submit, call to action
<header>, <nav>, <main>, <footer> Semantic page landmarks Page structure

Start with headings, paragraphs, links, images, and lists. Add forms and tables when your first page needs them. Add semantic tags when you learn the structure section below. Resist the urge to memorize the full reference; real skill comes from using the same 20 tags on real pages until they feel automatic.

How Do You Add Links, Images, and Lists to a Page?

Headings and paragraphs alone make a document, but links, images, and lists make a web page. These three groups appear on nearly every page on the internet, so practice them until they feel natural.

Links

The anchor element <a> creates a link. The href attribute holds the destination, and the text between the tags is what the visitor clicks. A link to another website uses a full address:

<a href="https://www.wikipedia.org">Visit Wikipedia</a>

A link to another page on your own site uses a relative path, which is just the file name:

<a href="about.html">About Us</a>

A link to a section on the same page uses an id value with a hash sign:

<a href="#contact">Jump to Contact</a>

Write link text that describes the destination, such as Download the guide, instead of Click here. Descriptive link text helps every visitor, including people who use screen readers, and it helps search engines understand the linked page.

Images

The image element <img> embeds a picture. It is an empty element, so it has no closing tag, and it needs two attributes at minimum: src for the file location and alt for the text description. The alt text describes the image for people who cannot see it and for search engines, and it appears if the image fails to load:

<img src="sunset.jpg" alt="A sunset over the sea" width="600" height="400">

The width and height attributes reserve space on the page so the layout does not jump while the image loads. Keep image files in the same folder as your HTML file while learning, or in a subfolder such as images, and write the path relative to the HTML file. Always add alt text. An empty alt attribute is correct only for purely decorative images, and a missing alt attribute is a mistake on any real page.

Lists

HTML has two list types. An unordered list <ul> shows bullets and is right for items with no ranking, such as features. An ordered list <ol> shows numbers and is right for steps or rankings. Each item uses the <li> tag:

<ul>
  <li>HTML for structure</li>
  <li>CSS for style</li>
  <li>JavaScript for behavior</li>
</ul>
<ol>
  <li>Open your text editor</li>
  <li>Write the HTML skeleton</li>
  <li>Save the file as index.html</li>
  <li>Open it in your browser</li>
</ol>

Lists can nest inside each other. A list item can contain another list, which is how navigation menus with submenus are built. Keep nesting to two levels while learning, because deeper nesting gets hard to read.

How Do You Build a Complete Web Page with HTML?

how to html

Now put everything together into one complete page. The example below is a small personal page with a header, navigation, an about section, a skills list, and a footer. Copy the whole block into a new file called about-me.html, save it, and open it in your browser. Then change the text to your own words and watch the page become yours.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>About Sara: Learning Web Development</title>
</head>
<body>
  <header>
    <h1>Sara Ahmed</h1>
    <p>Learning web development, one tag at a time.</p>
    <nav>
      <a href="#about">About</a>
      <a href="#skills">Skills</a>
      <a href="#contact">Contact</a>
    </nav>
  </header>
  <main>
    <section id="about">
      <h2>About Me</h2>
      <p>I am learning HTML so I can build my own website.
      This page is my first practice project.</p>
      <img src="sara-photo.jpg" alt="Portrait of Sara Ahmed smiling" width="300" height="300">
    </section>
    <section id="skills">
      <h2>Skills I Am Learning</h2>
      <ul>
        <li>HTML for page structure</li>
        <li>CSS for page style</li>
        <li>JavaScript for page behavior</li>
      </ul>
    </section>
    <section id="contact">
      <h2>Contact</h2>
      <p>Email me at <a href="mailto:sara@example.com">sara@example.com</a>.</p>
    </section>
  </main>
  <footer>
    <p>Built with HTML by Sara Ahmed, 2026.</p>
  </footer>
</body>
</html>

Notice the new line in the head: <meta name="viewport" content="width=device-width, initial-scale=1.0">. The viewport meta tag tells mobile browsers to show the page at the device width instead of zooming out to a desktop width. Add it to every page you build, because most visitors now browse on phones. Notice also that the heading order follows a clear outline: one h1 for the page title, then h2 for each section. Never skip from h1 to h3, and never use a heading just to make text big. Headings describe structure, and search engines and screen readers use them to understand your page.

Practice: change one thing at a time

After the page works, change one thing, save, and refresh. Add a second paragraph to the about section. Add a third skill to the list. Change the page title. Add an ordered list of your three favorite websites with links. Each small change teaches you more than reading another chapter, because you see the cause and the effect immediately. When something breaks, undo the last change and try again. That is debugging, and it is a normal part of writing HTML, not a sign of failure.

What Is Semantic HTML and Why Does It Matter?

Semantic HTML means choosing tags that describe what content is, not just how it should look. A <div> says nothing about its content. A <header>, <nav>, <main>, <article>, <section>, <aside>, or <footer> says exactly what its content is. Search engines use these tags to understand a page, screen readers use them to let blind users jump between sections, and other developers use them to read your code faster.

Before: div soup

Many beginners wrap everything in divs, because divs work and ask no questions. The result is hard to read and hard to maintain:

<div>
  <div>
    <h1>My Blog</h1>
  </div>
  <div>
    <a href="#">Home</a>
    <a href="#">About</a>
  </div>
  <div>
    <h2>First Post</h2>
    <p>Welcome to my blog.</p>
  </div>
  <div>
    <p>Copyright 2026</p>
  </div>
</div>

After: semantic HTML

The same page with semantic tags says what each part is:

<header>
  <h1>My Blog</h1>
</header>
<nav>
  <a href="#">Home</a>
  <a href="#">About</a>
</nav>
<main>
  <article>
    <h2>First Post</h2>
    <p>Welcome to my blog.</p>
  </article>
</main>
<footer>
  <p>Copyright 2026</p>
</footer>

Both versions look the same in a browser without CSS, but the second version is better in every other way. A search engine can tell which part is the navigation and which part is the article. A screen reader can offer a shortcut to jump straight to the main content. A developer opening the file a year later can understand the layout in seconds. Use a div only when no semantic tag fits, such as a wrapper for styling, and use semantic tags everywhere else. For a deeper look at how HTML shapes real sites, read our guide to HTML Web Development.

How Do You Check and Fix Your HTML?

how to html

HTML is forgiving: browsers guess what you meant when a tag is wrong. That forgiveness hides mistakes, so check your work with tools instead of trusting your eyes.

Validate with the W3C validator

The W3C Markup Validation Service, at validator.w3.org, is the official checker for HTML. Paste your code or upload your file, and it lists every error and warning with a line number and a plain explanation. Common findings include an unclosed tag, a missing alt attribute, a duplicated id, and a stray closing tag. Fix the first error first, because one unclosed tag often causes several reported errors below it. Make validation a habit: check every page before you call it done.

Inspect with browser DevTools

Press F12 to open Developer Tools, then click the Elements panel. It shows the live DOM tree of your page, and you can click any element to see its HTML and its position. Right-click any part of a page and choose Inspect to jump straight to that element. DevTools also has a Console tab that shows errors, such as a missing image file or a broken link. If an image does not appear, open the Console first: a 404 error there tells you the file path is wrong, which is the most common beginner problem.

Common beginner mistakes and their fixes

Mistake What happens Fix
Forgetting the closing tag The rest of the page inherits the formatting Close every tag you open, in reverse order
Saving as .txt instead of .html The browser shows raw code as text Save with the .html extension and All Files type
Wrong image path A broken image icon appears Keep images beside the HTML file and check spelling and case
Missing alt text Screen readers skip the image, SEO suffers Add a short descriptive alt to every image
Using a heading for big text Screen readers announce a fake section Use headings for structure only, style size with CSS
Skipping heading levels Confusing page outline Use h1 once, then h2, then h3 in order
Nesting tags in the wrong order Browsers guess and may render oddly Close the last opened tag first
Copying code from a word processor Curly quotes and hidden formatting break tags Paste code into a plain text editor only
Forgetting the doctype The browser enters quirks mode and renders inconsistently Put <!DOCTYPE html> as the first line
Using tables for page layout Messy code, poor mobile behavior, bad accessibility Use tables for data only, layout belongs to CSS

What Should You Learn After HTML?

HTML is the first of three core web technologies, and the other two build directly on it. Learn them in order, and give each one a small project before moving on.

CSS: style your pages

CSS, or Cascading Style Sheets, controls colors, fonts, spacing, and layout. Once your HTML page works, a single CSS file can turn it from plain black text into a designed page. Start with selectors, colors, fonts, the box model, and Flexbox. Style the about-me page from this guide as your first CSS project: center the content, add a background color, and style the navigation links.

JavaScript: add behavior

JavaScript adds interaction: buttons that respond to clicks, forms that check input before sending, menus that open and close, and content that updates without reloading the page. Learn variables, functions, and events, then add a small script to your about-me page, such as a button that shows or hides a section. Our guide to What Is Web Development explains how the three technologies fit into the full web development picture.

A 7-day practice plan

  • Day 1: Build the first page from this guide, then change the text and add a second paragraph.
  • Day 2: Add links to three favorite websites and an image with correct alt text.
  • Day 3: Build a page with an ordered list of steps and an unordered list of features.
  • Day 4: Rebuild the complete about-me page from memory, checking the guide only when stuck.
  • Day 5: Convert the page to semantic HTML with header, nav, main, section, and footer.
  • Day 6: Add a table with real data, such as a weekly schedule, and a simple form with a name field and a button.
  • Day 7: Validate both pages with the W3C validator, fix every error, and publish the better page on a free host such as GitHub Pages or Netlify to share the link with a friend.

Frequently Asked Questions

Is HTML a programming language?

No, HTML is a markup language, not a programming language. It describes the structure and meaning of content, but it has no logic, variables, loops, or calculations. Browsers read HTML tags and display the content they describe. Programming languages such as JavaScript add logic and behavior on top of the structure that HTML provides.

How long does it take to learn HTML?

Most beginners can build a simple page on the first day and learn the 20 most useful tags within one to two weeks of steady practice. Reaching comfortable fluency, including semantic HTML, forms, tables, and validation, usually takes three to four weeks at about an hour a day. HTML is widely considered the easiest first step into web development.

Do I need to install anything to learn HTML?

No, you need only a text editor and a web browser, and every computer already has both. A free editor such as Visual Studio Code makes learning easier with colored tags and automatic suggestions, but even Notepad is enough for your first pages. You do not need a server, a domain, or hosting until you want to share a page publicly.

What is the difference between HTML and HTML5?

HTML5 is the name of the version of HTML released in 2014, and it added semantic tags, audio and video elements, and form improvements. The current standard is called the HTML Living Standard, maintained by WHATWG, and it updates continuously instead of using version numbers. In everyday conversation, people still say HTML5 to mean modern HTML.

Can I build a website with HTML alone?

Yes, you can build a complete static website with HTML alone, and every website needs HTML as its base. An HTML-only site works, but it will look plain without CSS and will not respond to clicks without JavaScript. For a finished, professional site, combine HTML for structure, CSS for style, and JavaScript for behavior.

What is the most common HTML mistake beginners make?

The most common mistake is forgetting a closing tag, which makes the rest of the page inherit the wrong formatting. The second most common is saving the file with the wrong extension, such as .txt, so the browser shows raw code instead of a page. Both are easy to fix, and the W3C validator catches them in seconds.

Conclusion

Learning how to HTML is the fastest way to go from reading the web to building it. You now know what HTML is, which two tools you need, how to write your first page, what tags, elements, and attributes mean, and which 20 tags cover most real pages. You also have a complete page to build, a semantic HTML before-and-after example, a validation workflow, and a 7-day plan to keep practicing.

Open your text editor and build the first page today, while the steps are fresh. Change the text, break something, fix it, and validate the result. That loop of writing, viewing, and fixing is how every web developer learned, and your first finished page is closer than you think. When it works, add CSS next and watch the same page turn into a designed site.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *