Jens Oliver Meiert

Get 15% off on select books on Gumroad—use discount code “testdrive”.

The 6 Ways of Writing HTML (and Their Combinations)

Post from November 23, 2021 (↻ June 26, 2022), filed under .

Everyone can write HTML, until they find out they can’t. HTML, currently clocking in at 2,185 pages (PDF), is massive, and there’s evidence that it takes study and practice to master.

(The hubris exists and is significant. With so many people saying they know HTML, the attitude towards HTML is the IT industry’s equivalent to Germany having 80 million professional football coaches.)

Because of specification size and complexity, as well as differences in developer attitude and professionalism, there are several ways of writing HTML (6), and combinations thereof (19). This article documents these ways and combinations. If the reasoning is correct, everyone’s particular way of HTML should be reflected, allowing to consciously opt for another, if desired.


  1. The 6 General Ways of Writing HTML
    1. Unsystematic
    2. Valid
    3. Semantic
    4. Accessible
    5. Required-Only
    6. Hyper-Optimized
  2. The 19 Combinations of Writing HTML
    1. Popular Combinations of Writing HTML
    2. Recommended Combinations of Writing HTML

The 6 General Ways of Writing HTML

1. Unsystematic

This HTML writing style is naive or, nicer, unsystematic. The elements of HTML are not yet learned, the idea of semantics not entirely understood, output verification lacking when it comes to testing and not existing for validation, optimization options not yet known, and concepts like accessibility still foreign.

It’s usually the incomplete map of HTML elements that contributes the most to this style, where pragmatism reigns and where “divitis” and “classitis” are among the symptoms.

An example for the unsystematic type is this, taken from a random live site. The code is all over the place and it’s hard to consider the work professional:

  <!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" lang="en-US">
<!--[if IE 8]>
<html class="ie ie8" lang="en-US">
<!--[if !(IE 7) & !(IE 8)]><!-->
<html lang="en-US">
<!-- snip -->


<body class="home page-template page-template-page-templates page-template-page-homepage page-template-page-templatespage-homepage-php page page-id-23 custom-font-enabled single-author">

    <!-- snip -->
      <script type="text/javascript">
      // snip

<div id="page" class="hfeed site">
  <header id="masthead" class="site-header" role="banner">
    <div id="hamburger-menu"><span></span><span></span><span></span></div>

    <a href=""><img id="pagelogo" src=""></a>

    <nav id="site-navigation" class="main-navigation" role="navigation">
      <div class="secondmenusection">
        <div class="menu-main-menu-container"><ul id="menu-main-menu" class="nav-menu"><li id="menu-item-262" class="work menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-262"><a href="">Work</a>
<ul class="sub-menu">
  <li id="menu-item-265" class="all menu-item menu-item-type-custom menu-item-object-custom menu-item-265"><a href="">Main</a></li>
  <li id="menu-item-562" class="menu-item menu-item-type-taxonomy menu-item-object-gal-categories menu-item-562"><a href="">Classic</a></li>
<li id="menu-item-21" class="biography menu-item menu-item-type-post_type menu-item-object-page menu-item-21"><a href="">Biography</a></li>
<li id="menu-item-942" class="download hide_item__ menu-item menu-item-type-post_type menu-item-object-page menu-item-942"><a href="">Download</a></li>
<li id="menu-item-22" class="contact menu-item menu-item-type-post_type menu-item-object-page menu-item-22"><a href="">Contact</a></li>
<li id="menu-item-299" class="instagram menu-item menu-item-type-custom menu-item-object-custom menu-item-299"><a target="_blank" rel="noopener" href=""><i class="fa fa-instagram"></i></a></li>
</ul></div>        <p class="create_foo"><span class="create_foo_icon"></span><span class="create_foo_text">Create Foo</span></p>
        <p class="client_login login"><span class="client_login_icon"></span><span class="client_login_text">Client Login</span></p>

    <div id="zooms">
      <span class="fa plus"></span>
      <span class="fa minus"></span>
      <span class="fa grid"></span>
      <!--<i class="fa fa-plus"></i>
      <i class="fa fa-minus"></i>-->

    <span class="float-down-arrow"></span>

<!-- stop stop snip -->

2. Valid

The next succinct HTML style revolves around a baseline quality attribute for HTML: It’s valid. That’s sometimes all that is to see here, as the markup may not make the best use of elements yet. But, a sign of a professional developer attitude and of getting the basics right, at least the code is syntactically correct.

Here, an example for a valid page (by myself, only out of convenience):

<!DOCTYPE html>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1,minimum-scale=1,width=device-width">
<meta property="og:image" content="">
<title>Have We Stopped Killing Yet?</title>
<link rel=icon href=favicon.ico>
<link rel=stylesheet href=setup/default.css>
<h1>Have We Stopped Killing<a href=><sup>*</sup></a> Yet?</h1>
<p>This is unacceptable.
<p>We don’t need arms and armies and industrial slaughterhouses.
<p>We need respect for life.
<p>Everyone can <em>do something</em>. Speaking up is doing something. <a href=><img src= alt="Jens Oliver Meiert"></a>

3. Semantic

Another HTML style is the semantic one. Here, noticeable attention is being paid to using the correct elements and, if available, microformats or microdata. This style exhales the idea of meaning in HTML, with a palpable desire not to resort only to div elements.

The following is an example, also by myself (not because of me but because it’s hard to find a page that is long enough to serve as an example, but not so long as to dominate an article; and at the same time use enough markup to be meaningful, but not so much as to cloud the point):

<!DOCTYPE html>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1,minimum-scale=1,width=device-width">
<meta name=description property=og:description content="Edited">
<meta name=twitter:card content=summary>
<meta property=og:title content=" · Web Development Tools · Analyze Your Website, Explore Dev Tools">
<meta property="og:image" content="">
<title> · Web Development Tools · Analyze Your Website, Explore Dev Tools</title>
<link rel=stylesheet href=>
<link rel=alternate href=/feed/ type=application/rss+xml title="All tools">
  <img src=>
<section id=check>
  <h1><a href=/check/>Site Check</a></h1>
  <p>Test your website in more than 80 tools:
  <form action=/check/results/ method=post>
    <label for=url>URL:</label>
    <input type=url name=url id=url required inputmode=url placeholder=https://>
  <h1><a href=/analysis/>Analyze Your Website</a></h1>
  <p><a href=/analysis/#general>General</a>, <a href=/analysis/#accessibility>Accessibility</a>, <a href=/analysis/#code>Code</a> <!-- snip -->
  <p> favorite: <a href=>Website Performance Analysis (WebPageTest)</a>
  <h1><a href=/exploration/>Explore Dev Tools</a></h1>
  <p><a href=/exploration/#testing>Browser Testing</a>, <a href=/exploration/#auditing>Code Auditing</a>, <a href=/exploration/#generation>Code Generation</a> <!-- snip -->
  <p> favorite: <a href=>Color Scheme Generator (Coolors)</a>
  <h1>Stay Up-to-Date</h1>
  <p>The latest additions to (usually one per week):
    <li><a href=>HTTP/3 Test</a>
    <li><a href=>Google Title Rewrite Check</a>
    <li><a href=>Image Performance Analysis</a>
  <p>Never miss new tools: <a href=/feed/>Subscribe to RSS feed</a> or <a href=>follow on Twitter</a>.
    <li><a href=/feed/>Feed</a>
    <li><a href=>Twitter</a>
    <li><a href=/analysis/>Analysis</a>
    <li><a href=/exploration/>Exploration</a>
    <li><a href=/check/>Site Check</a>
    <li><a href=/contact/>Contact & Legal</a>
  <p>Last update: September 22, 2021
  <p> for people who test websites ✓
  <p id=promo>Learning Web Development? Check out the <a href=>Web Development Foundations book bundle</a>!

4. Accessible

A style distinct even from the semantic style (more on that in a second) is the accessible one. This one prioritizes accessibility over everything else and can typically be recognized by two things: WCAG focus as well as eager (and sometimes overeager) use of ARIA:

<!DOCTYPE html>
<html lang="en">

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <meta name="theme-color" content="#e6e6e6" media="(prefers-color-scheme: light)">
  <meta name="theme-color" content="#636366" media="(prefers-color-scheme: dark)">
  <link rel="canonical" href="" />

<title>Home · Example</title>
<meta content="" name="description">
<meta content="" name="keywords">

<meta content="Home · Example" property="og:title">
<meta content="website" property="og:type">
<meta content="Example" property="og:site_name">
<meta content="" property="og:url">
<meta content="" property="og:image">
<meta content="" property="og:description">
<meta content="en_GB" property="og:locale">

<!-- snip -->

<meta content="index, follow, noodp" name="robots">

    <link href="" rel="stylesheet">
<link href="" rel="stylesheet">
<link href="" rel="stylesheet">
  <link rel="openid.delegate" href="">
  <link rel="openid.server" href="" />
  <link rel="openid2.provider" href="" />
  <meta data-embetty-server="">
  <link rel="shortcut icon" type="image/x-icon" href="">
  <link rel="alternate" type="application/rss+xml" title="Latest articles" href=""/>
  <link rel="alternate" type="application/json" title="Latest articles" href=""/>
  <script defer data-domain="" src=""></script>


  <header class="header">
        <a class="logo" href="">
      Example    </a>

    <nav class="menu" aria-label="main">
                  <a  href="">Blog</a>
            <a  href="">Videos</a>
            <a  href="">Talks</a>
            <a  href="">About</a>
            <span class="social">
    <a href="" aria-label="Twitter">
    <!-- snip -->  </a>
    <a href="" aria-label="YouTube">
    <!-- snip -->  </a>

  <main class="main">

<header class="h1">
    <p class="subheadline">Edited</p>

<div class="text">
  <img class="avatar" src="" alt="Example, edited.">
  <p>Edited.</p><div class="clients">
  <h2 class="h2">Recommended By:</h2>
  <div class="gallery">
        <img role="img" src="" alt="Edited">
        <img role="img" src="" alt="Edited">
        <img role="img" src="" alt="Edited">
        <img role="img" src="" alt="Edited">
        <img role="img" src="" alt="Edited">
<div id="insert_steady_checkout_here" style="display: none;"></div>


  <footer class="footer">
    <div class="grid">
      <section class="column" style="--columns: 8">
      <section class="column" style="--columns: 2">
          <li><a href="">RSS Feed</a></li>
          <li><a href="">JSON Feed</a></li>
      <section class="column" style="--columns: 2">
        <!-- snip -->

  <script src=""></script>
<script src=""></script>
<script src=""></script>


Why is this not the same as the semantic style? In short, because the semantic and accessible approaches reflect two different schools; they walk a good part of the way together, but they’re not identical. A technical manifestation of this is that the semantic school often makes use of microformats and microdata, while the accessible school likes ARIA.

A more general view is that accessible markup must not by necessity be semantic—at least not if you assign the native meaning of HTML elements more weight than that of added-on ARIA markup. In other words, we cannot—a semantic school advocate would not—view <h1>Heading</h1> and <div role=heading aria-level=1>Heading</div> as equivalent. That would need to be the case to defend the idea that the accessible way of writing HTML is necessarily also the semantic one.

5. Required-Only

With the “required-only” HTML writing style, the idea is only to use the markup (as well as other code) that is strictly needed. It is the style of minimal web development and the one that avoids using optional markup, even in development.

The required-only style gives you boilerplate HTML like this, not only shedding optional code but also the idea that one could actually have any boilerplate HTML:

<!DOCTYPE html>

6. Hyper-Optimized

The final style we can distinguish is the one of “hyper-optimized” HTML. This is the style that uses anything to minimize code and payload—as such it is a subset of the “required-only” style—, including parse errors. Barely anyone ever uses this style—for both good and bad reasons.

The bad reason first: HTML is decades old, but with some developers luring themselves into knowing it after five minutes, the highest step in evolution for a frontend developer can often be the unsystematic style, and in some cases the semantic one.

The good reason is that the hyper-optimized style is super-hard to play, with marginal returns and no (or little) tooling to support. We can probably be happy no one makes use of this style.

<!doctypehtml><title>Everyone knows HTML</title><img alt="My logo"src=logo><! TODO: write rest of doc >

This code is completely made up. It’s not valid. It works. It makes use of the “missing-whitespace-between-attributes” and “incorrectly-opened-comment” parse errors. It’s hyper-optimized.

The 19 Combinations of Writing HTML

The 6 general ways of writing HTML now lead to the following 19 combinations of writing HTML. It’s a list of ways that are compatible with each other.

The list doesn’t include random combinations—for example, when a unsystematically written document happens to be valid.

  1. Unsystematic
  2. Valid
  3. Valid, semantic
  4. Valid, semantic, accessible
  5. Valid, semantic, accessible, required-only
  6. Valid, accessible
  7. Valid, accessible, required-only
  8. Valid, required-only
  9. Semantic
  10. Semantic, accessible
  11. Semantic, accessible, required-only
  12. Semantic, accessible, required-only, hyper-optimized
  13. Semantic, required-only
  14. Semantic, required-only, hyper-optimized
  15. Accessible
  16. Accessible, required-only
  17. Accessible, required-only, hyper-optimized
  18. Required-only
  19. Required-only, hyper-optimized

These are the 19 specific ways we write HTML.

Does this miss a combination, or have I not explained something well? Let me know!

Popular Combinations of Writing HTML

When you go through the list, you’ll notice that some styles are styles we advocate and aspire to, that others feel common, and that a couple look unusual. I’d roughly order the main ones like this, in descending order of perceived popularity:

  1. Unsystematic (a large part of web pages)
  2. Semantic (largest minority style)
  3. Accessible
  4. Semantic, accessible
  5. Valid, semantic (quite rare, <2% of web pages)
  6. Valid, accessible

Recommended Combinations of Writing HTML

Identifying HTML writing styles and recommending HTML writing styles are, I believe, the real use cases for this categorization. In my mind, the following are the styles we should promote, in ascending order of both usefulness and difficulty:

  1. Valid
  2. Valid, semantic, accessible
  3. Valid, semantic, accessible, required-only

Why this order?

  1. Valid: baseline quality bar to aim for; invalid markup is unprofessional.
  2. Valid, semantic, accessible: semantic markup is largely accessible markup; although there’s one to be made (see earlier notes), there seems little merit in emphasizing the distinction.
  3. Valid, semantic, accessible, required-only: as a general rule, it makes sense to also leave out optional code.

Even if our field was so advanced as to be ready for the hyper-optimized style, the gains are too small to sacrifice the great value of validity (which is incompatible with it) as a quality standard. It is an HTML writing style, but a hypothetical rather than a practically useful one.

❧ These are the 6 ways of writing HTML, and their 19 combinations. Which way or combination is yours? Which one do you aspire to? Follow up on this post’s tweet, or reach out directly! And while I recommend everyone to make the valid way part of their own style, it’s important to internalize this: HTML is the most important web standard.

Many thanks to Thomas Steiner for reviewing this post.

About Me

Jens Oliver Meiert, on September 30, 2021.

I’m Jens, and I’m an engineering lead—currently manager for Developer Experience at LivePerson—and author. I’ve worked as a technical lead for Google, I’m close to W3C and WHATWG, and I write and review books for O’Reilly. I love trying things, sometimes including philosophy, art, and adventure. Here on I share some of my views and experiences.

If you have a question or suggestion about what I write, please leave a comment (if available) or a message. Thank you!

Read More

Have a look at the most popular posts, possibly including:

Looking for a way to comment? Comments have been disabled, unfortunately.

Cover: The Web Development Glossary.

Get a good look at web development? Try The Web Development Glossary (2020). With explanations and definitions for literally thousands of terms from Web Development and related fields, building on Wikipedia as well as the MDN Web Docs. Available at Apple Books, Kobo, Google Play Books, and Leanpub.

Stay up-to-date? Learn about new posts by feed or on Twitter.

Found a mistake? Email me,

You are here: HomeArchive2021 → The 6 Ways of Writing HTML (and Their Combinations)

Last update: June 26, 2022

Professional frontend developers produce valid HTML and CSS.