Skip to content
Learn Netverks

Lesson

Step 3/58 5% through track

basics

HTML basics

Last reviewed May 28, 2026 Content v20260528
Track mode
iframe_html
Means
HTML preview sandbox
Reading
~3 min
Level
advanced

This lesson

This lesson teaches HTML basics—the ideas, syntax, and habits you need before moving on in HTML.

Without a solid grasp of HTML basics, you will repeat mistakes in HTML exercises and on real pages or scripts.

You will apply HTML basics in contexts like: Websites, hybrid apps, email templates, design systems, and CMS-driven content.

Read the lesson, edit HTML/CSS in the playground, press Run to preview, then answer the lesson MCQs. Also use the HTML reference desk when you need tag or attribute lookup.

When intermediate lessons feel comfortable and you are ready for production-style trade-offs.

An HTML document is a tree of nested elements. The parser follows explicit rules so that even imperfect markup yields a predictable DOM—still, write valid HTML to avoid surprises across browsers.

Doctype and root element

<!DOCTYPE html> is the single required preamble for modern HTML. It must appear once at the top so the browser uses standards mode instead of legacy quirks.

The root <html> wraps exactly two primary children in typical pages: head and body. Nothing useful belongs outside them except DOCTYPE.

Normal elements vs void elements

  • Normal elements have a start tag, optional content, and an end tag: <p>…</p>.
  • Void elements cannot contain children—examples include img, br, meta, link, input. In HTML syntax you omit the closing slash (optional in XML-style).

Nesting rules

Close the most recently opened element first (“stack” discipline). Invalid nesting (e.g. block elements stuffed inside inline-only contexts without fixing structure) forces parsers to infer fixes that may not match your intent.

<p>This paragraph contains <strong>nested emphasis</strong>.</p>

Rendered

This paragraph contains nested emphasis.

Void elements cheat sheet

<img src="/a.webp" alt="">
<br>
<input type="text" name="q">
<meta charset="utf-8">
<link rel="stylesheet" href="/app.css">

None of these accept a closing </tag> with inner HTML—everything lives in attributes.

Whitespace demo

Collapsed in normal paragraphs vs preserved in pre

Line one Line two extra spaces → collapse in a p.

Line one
Line two

Case sensitivity

HTML tag and attribute names are ASCII case-insensitive in HTML documents, but lowercase is universal convention. Attribute values may be case-sensitive depending on context (e.g. id vs MIME types).

Whitespace

Multiple spaces and newlines usually collapse to single spaces in normal flow text nodes—use CSS white-space or pre when you need preserved formatting.

What bites developers in practice

  • Optional tags: the parser may imply html, head, body, or closures for p/li. Valid explicit markup is clearer for humans and tooling.
  • Interactive nesting: you cannot legally nest anchors, buttons, or other interactive elements—violations create unpredictable clickable regions.
  • Void elements: <br>, <img>, <input> etc. cannot hold children—if you mentally model them like components with slots, reset that mental model.

Why this mastery matters

Bug reports labeled “CSS issue” often trace back to malformed HTML that the parser quietly corrected. Debugging starts by comparing source → DOM tree → computed styles.

Important interview questions and answers

  1. Q: What is the purpose of ``?
    A: It forces standards mode so browsers use modern layout/parsing behavior instead of legacy quirks mode.
  2. Q: Why is semantic HTML important in interviews and production?
    A: It improves accessibility, SEO, maintainability, and reduces ARIA/JS work by using native element behavior.
  3. Q: What is the difference between `head` and `body`?
    A: `head` stores metadata/resources for the document, while `body` contains user-visible content.

Tip: View page source on sites you admire—notice DOCTYPE and lang first.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • What confused you about this lesson?
  • How would you explain this to a teammate in 30 seconds?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump