Tutorial

HTML and CSS basics: your first web page

Every web page you have ever visited is built from two languages. HTML says what things are. CSS says how they look. Learn those two jobs and the rest of web development starts making sense.

HTML: what things are

HTML stands for HyperText Markup Language. You write your content inside tags, and the tags tell the browser what each piece of content means:

<h1>My first heading</h1>
<p>This is a paragraph of text.</p>
<a href="https://parhodev.com">A link to somewhere</a>

A tag usually comes in an opening and closing pair. Some tags carry attributes, extra information inside the opening tag. In the example above, href tells the link where to go.

The smallest complete page

Every HTML page follows the same skeleton:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>My first page</title>
</head>
<body>
  <h1>Hello, web</h1>
  <p>This is my first web page.</p>
</body>
</html>

The first line looks like a leftover from 1999, but it matters: it puts the browser in standards mode. This exact line, <!DOCTYPE html>, is the correct doctype for every modern page, confirmed in the WHATWG's own FAQ.

There is no HTML6

Worth knowing early: HTML has no version numbers. The WHATWG maintains it as a single living standard that browsers implement continuously. When people say "HTML5", they mean the modern feature set, not a version you can fall behind on.

Semantic HTML: tags that mean something

You could build an entire page out of <div> tags and it would look fine. But HTML offers tags that describe meaning, and meaning matters: screen readers use these tags to help blind users navigate, and search engines use them to understand the page.

TagUse it for
<header>Introductory content, usually the top of the page or a section
<nav>Navigation links
<main>The main content (one per page)
<section>A thematic group of content, usually with a heading
<article>A self-contained piece, like a blog post
<footer>Closing content: contact info, copyright, small print

Rule of thumb: pick the tag that matches the meaning, then let CSS handle how it looks.

CSS: how things look

CSS (Cascading Style Sheets) is a separate language that targets your HTML and styles it. The pattern is always the same: a selector picks elements, then declarations describe the styling:

h1 {
  color: #1e40af;
  font-size: 2rem;
}

While learning, put CSS in a <style> block inside the <head>. For real projects, keep it in a separate .css file and link it:

<link rel="stylesheet" href="styles.css">

The box model: the idea behind half of all layout confusion

Every element on a page is a box made of four layers, from the inside out: content, padding, border, margin. Padding is space inside the box, around the content. Margin is space outside it, pushing other boxes away.

Here is the classic beginner trap, confirmed in MDN's own docs: in the default box model, width: 300px sets only the content box. Add 20px of padding and a 2px border and the box actually takes up 344px on the page. Your careful layout quietly breaks.

The fix nearly every developer uses: box-sizing: border-box, which makes width mean the visible box, padding and border included. Apply it to everything and widths finally add up:

html {
  box-sizing: border-box;
}
*, *::before, *::after {
  box-sizing: inherit;
}

Mistakes every beginner makes

MistakeWhy it hurtsDo this instead
Styling with HTML tags like <font>Mixes content and styling; outdated for decadesUse CSS for all visual styling
<div> for everythingScreen readers and search engines see no structureUse semantic tags from the table above
Images with no alt textBreaks for blind users and when images fail to loadDescribe the image in one short phrase
Skipping box-sizingWidths never add up; layouts driftborder-box on everything, from day one
px for all font sizesIgnores users who set larger default textUse rem for text sizes

Your first complete page

Put it all together. Save this as index.html and open it in a browser:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>My first page</title>
  <style>
    html { box-sizing: border-box; }
    *, *::before, *::after { box-sizing: inherit; }
    body { font-family: system-ui, sans-serif; max-width: 40rem; margin: 2rem auto; padding: 0 1rem; }
    h1 { color: #1e40af; }
  </style>
</head>
<body>
  <header>
    <h1>Hello, web</h1>
  </header>
  <main>
    <p>This is my first web page. HTML gave it meaning, CSS gave it style.</p>
  </main>
</body>
</html>

That is a real web page: semantic tags, a stylesheet, and the box model fix in place. Everything from here is vocabulary, not new concepts.

Frequently asked questions

Is HTML a programming language?

No. It is a markup language: it describes and structures content but cannot compute anything. Making pages do things is JavaScript's job, which comes next.

Should I learn HTML or CSS first?

HTML first, then CSS. You need something to style before styling makes sense. A week of HTML followed by CSS is a sane order.

Do I need special software to write HTML?

No. Any text editor works. VS Code is the common free choice because it highlights mistakes as you type.

Last verified: October 27, 2026, against the WHATWG HTML Standard and MDN Web Docs. HTML is a living standard, so the WHATWG FAQ and MDN remain the reference if you are reading this later.

Want this done for you instead?

Tutorials teach the craft. If you need the finished product, we build it.

Get a quote →

← All tutorials