Skip to content
Learn Netverks

Lesson

Step 32/58 55% through track

style-guide

HTML conventions

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

This lesson

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

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

You will apply HTML conventions 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.

Consistency enables teams to navigate templates quickly and automated tools to enforce policies.

Formatting

  • Indent nested blocks uniformly (two spaces is common).
  • Wrap long attribute lists one attribute per line.
  • Close void elements without slashes unless integrating XML pipelines.

Attribute ordering (example)

idclassdata-*aria-* → event handlers—pick a documented order.

Linting & validation

  • HTML validators catch stray tags and illegal nesting.
  • Accessibility lint rules spot missing labels, low contrast (via integrations), invalid ARIA.

Documentation

Embed rationale comments near unusual markup (server-side comments preferred over client-visible HTML comments).

Performance hygiene

  • Remove commented-out markup before shipping.
  • Avoid enormous inline SVG blobs inside unrelated templates—split partials.

Why conventions pay rent

Uniform attribute ordering and naming reduce diff noise in large teams—time spent bikeshedding style is time not spent on security and accessibility reviews.

Example — readable attribute wrapping

<!-- Packed (hard to review in PRs) -->
<img src="/images/baby-icon.webp" alt="Course sample icon" width="120" height="80" loading="lazy" class="rounded-2xl">

<!-- Wrapped (diff-friendly) -->
<img
  class="rounded-2xl shadow-sm"
  src="/images/baby-icon.webp"
  alt="Rounded baby-face illustration from the course asset pack"
  width="525"
  height="350"
  loading="lazy"
>

Rendered (/public/images/baby-icon.webp)

Rounded baby-face illustration from the course asset pack

Pick one house style; Prettier plugins can enforce it.

Important interview questions and answers

  1. Q: What is the safest default character encoding for modern HTML?
    A: UTF-8, declared early with `` and matched by server `Content-Type` headers.
  2. Q: When are HTML entities still useful in UTF-8 pages?
    A: For reserved characters (`&`, `<`) and contexts where explicit escaping avoids parser ambiguity.
  3. Q: What is the key difference between HTML5 parsing and XHTML parsing?
    A: HTML5 recovers from many errors; XHTML (XML) treats many parse errors as fatal.

Tip: Lowercase tags, quoted attributes, and consistent indentation aid reviews.

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