How to Read a Web Spec Without Getting Lost

How to Read a Web Spec Without Getting Lost

Spec literacy is a small fixed vocabulary, not an expert skill — normative text vs notes, RFC 2119 MUST/SHOULD/MAY, reading algorithms and WebIDL, and a checklist for any spec.

Reading a web spec is a skill with a small fixed vocabulary, not an expert-only ability — and the primary source is the tie-breaker every time a second-hand summary is ambiguous, lagging, or wrong. The whole skill reduces to a handful of habits: read the status and conformance sections first, distinguish normative text from notes and examples, know exactly what MUST, SHOULD, and MAY license, trace a numbered algorithm one step at a time instead of all at once, and read the WebIDL block before the prose because it states types and surface precisely. This guide gives you each of those habits and a repeatable checklist you can apply to any specification regardless of which body owns it.

Why read the spec at all

Second-hand summaries are useful and they are not authoritative. Documentation sites, blog posts, and answers from other engineers lag the specification, simplify it deliberately, and occasionally contradict it — not out of carelessness but because a summary's job is to be approximately right quickly, and the spec's job is to be exactly right slowly. Most of the time approximate is enough. The times it is not are exactly the times that cost you: an edge case the summary flattened, a default the summary omitted, a behavior the summary described as it used to be. When the summary and reality disagree, the specification is the document that settles it, and a team that cannot open it is stuck arguing about which blog post is newer.

There is a second, less obvious reason to read the source: it tells you things a summary structurally cannot. A summary describes the common path. A specification aims to define the whole behavior, including the error cases, the ordering guarantees, the defaults that apply when an argument is omitted, and the precise point at which one operation is observable to another — and where it leaves something to implementations, it can say so explicitly (the ECMAScript specification calls such behavior "implementation-defined"). Those are exactly the parts that do not fit in a summary and exactly the parts that produce the bugs no one can reproduce on their machine. When the question is "what happens if two of these run concurrently" or "what is the state if this rejects halfway through," the summary will not have an answer; the spec is where that answer is defined, or where it is stated that the answer is left to implementations.

The good news is that spec literacy is not a deep expertise. It is a small set of conventions that recur across modern web specifications, each written down by the body that uses it — the framing that this topic's main guide makes is that standards are a defined process, and part of that definition is each body's house style for the documents themselves. Learn the conventions once and most of them carry across bodies: W3C and WHATWG specifications share WebIDL interface declarations and numbered step algorithms; the RFC 2119 requirement keywords appear in IETF RFCs such as RFC 9110 and in W3C and WHATWG specifications, though not with the same capitalization rule; and TC39's ECMAScript specification defines its own algorithm conventions and does not cite RFC 2119 or use WebIDL. Each document states the conventions it follows, so check them in each one rather than assuming a single house style. This article owns those reading mechanics; where a feature sits in its body's process, and whether a readable draft is actually safe to build on, are separate questions owned elsewhere on this topic and only pointed at here.

Normative vs non-normative

The first distinction to internalize is that only normative text defines conformance. Normative text is the part of the document an implementation must obey to be considered correct. The material a document's conformance section lists as non-normative (such as examples, notes, and diagrams), together with any section explicitly marked non-normative, is there to help you understand the normative text and carries no requirement of its own. An introduction or explanatory aside belongs to that group only if it is marked that way: conformance sections such as those of the W3C Payment Request API and the WHATWG Infra Standard state that everything else is normative.

This is not a pedantic distinction. Mistaking a note for a requirement causes real bugs in both directions. Build to an example that was only illustrative and you depend on behavior nothing guarantees; dismiss a normative sentence because it reads like a casual aside and you ship something non-conformant that breaks when an engine tightens its implementation. Specifications mark the difference explicitly: informative content is usually labeled as a note or example, or scoped into a section the document declares non-normative, while the rest of the body is normative whether or not it uses the requirement vocabulary covered below. Train your eye to ask, for any sentence you are about to depend on, whether it is normative — and if you cannot tell, that is itself a sign to slow down.

The trap is that examples are persuasive in a way prose is not. An example shows code that does a specific thing and returns a specific value, and it is tempting to treat that concrete result as the contract. It is not. An example is the author demonstrating one path through the normative text; it is correct only because the normative text makes it correct, and it covers only the inputs the author chose to show. If your usage differs from the example's inputs — a null where the example passed a value, a second call where the example made one — the example tells you nothing, and only the normative text does. A useful habit is to read the example last, after the normative section, as a check on your understanding rather than as the source of it. If your reading of the requirement predicts the example's outcome, you have read it correctly; if it does not, you have found either a misreading or a spec bug, and both are worth knowing.

The habit that makes this reliable is reading the status and conformance sections first, not last. Most engineers skip the front matter and dive at the feature. Reverse that. The "Status of This Document" or equivalent section tells you which body owns the spec and where the document stands in that body's process. The conformance section — in RFCs, a short section such as RFC 9110's "Requirements Notation"; in WHATWG standards such as HTML, the conformance rules of the Infra Standard they depend on — tells you, critically, how to interpret the rest of the document: how the requirement keywords are to be read and, in documents such as the W3C Payment Request API and the Infra Standard, what is non-normative. Reading them first is the difference between reading a document and guessing at one.

The requirement vocabulary

Normative requirements are expressed in a deliberately tiny controlled vocabulary, defined for the IETF in RFC 2119 and clarified by RFC 8174, and reused by W3C and WHATWG specifications. The words are ordinary English, which is exactly why they are dangerous if you read them as ordinary English. Each one licenses a precise set of assumptions:

  • MUST and MUST NOT are absolute. A conformant implementation has no discretion; you may rely on the behavior unconditionally and you may assume every conformant engine does too.
  • SHOULD and SHOULD NOT are strong recommendations with an escape hatch. A conformant implementation is allowed to deviate when it has a considered reason. It is easy to misread: an engineer who reads SHOULD as MUST builds on a behavior an engine is permitted to omit. If your code's correctness depends on a SHOULD, your code depends on an implementation choice, not on a guarantee.
  • MAY marks something truly optional. An implementation can do it or not; RFC 2119 adds that either way it MUST be prepared to interoperate with an implementation that made the other choice, though perhaps with reduced functionality. You cannot assume either choice across engines without checking each one.

RFC 8174 adds a subtlety worth knowing: in documents that adopt its wording, only the uppercase keywords carry this special meaning, and a lowercase "should" has its normal English meaning. WHATWG standards built on the Infra Standard deliberately do the opposite: Infra gives lowercase "must", "should", and "may" the same RFC 2119 meaning and calls this a "willful violation of RFC 8174", so in the normative text of the HTML Standard a lowercase "should" is a requirement keyword. Before you trust any of these words in a given document, find where the document declares that it uses RFC 2119 keywords and how — that declaration lives in the conformance section described above, not in the status section, which is one more reason to read both first.

There is a practical interoperability lesson buried in the SHOULD problem. When a spec says an implementation SHOULD do something, engines are permitted to differ, and over time they often do — one ships the recommended behavior, another takes the documented exception. Code that assumed SHOULD meant MUST works on the first engine and silently misbehaves on the second, and the failure looks like a browser bug when it is actually a misreading of the requirement level. Reading the keyword correctly is therefore not academic: it is the difference between knowing a behavior is guaranteed everywhere and knowing it is guaranteed nowhere in particular. MAY has the same hazard in a quieter form — an optional behavior present in the engine you tested is not present by contract, and treating its presence as reliable is the same mistake at a lower volume. The rule of thumb is simple: your code may depend on MUST without checking, must verify anything resting on SHOULD or MAY across the engines you owe, and should treat a behavior the normative text does not define at all as undefined — remembering that normative text binds implementations even when no keyword appears (RFC 8174 notes that a lot of normative text does not use the keywords, and the Infra Standard treats an algorithm introduced without one as still carrying an implied "must").

Reading algorithms and WebIDL

Browser API specifications from the WHATWG and the W3C do not rely on loose prose to describe behavior. They define it as numbered step algorithms and as interface declarations written in WebIDL (the ECMAScript specification uses numbered algorithms too, but not WebIDL), and both are far more precise — and faster to read — than the surrounding explanation once you know the form.

A WebIDL block tells you the surface shape of an API exactly: what exists, the types, what is nullable, what is read-only. Reading the IDL first orients you before a single paragraph of prose. A short, illustrative fragment looks like this:

webidl
[Exposed=Window]
interface ExampleThing {
  constructor(DOMString name);
  readonly attribute DOMString name;
  attribute unsigned long? count;
  Promise<undefined> refresh(optional ExampleOptions options = {});
};

You can read concrete facts straight off that without any prose: the interface is exposed on Window, the constructor takes a name string and the name attribute cannot be assigned from script (that the argument becomes the attribute's value is something the prose constructor steps define), count is writable and the ? means it is nullable, and refresh() is asynchronous because it returns a Promise and takes an optional options dictionary that defaults to empty. The full grammar is defined in the WebIDL specification; you do not need all of it to extract the shape of an API, you need the handful of markers — nullability, readonly, optional, return types — that recur everywhere.

Algorithms are the other half. A spec defines behavior as ordered steps, often with sub-steps and explicit branching, written so that two independent implementations produce the same observable result. An illustrative, made-up algorithm in that style:

text
To resolve a thing given input:
  1. If input is null, return failure.
  2. Let result be a new Thing.
  3. For each item of input's entries:
     1. If item is not valid, continue.
     2. Append item to result's list.
  4. Return result.

The mistake is trying to hold the whole algorithm in your head at once. Do not. Trace one step at a time, treating each numbered line as a single operation and each sub-list as a loop or a branch, and write down the state if it helps — the algorithm is written to be executed mechanically, so execute it mechanically rather than intuiting it. Pick a concrete input, run it through the steps on paper, and note the value of each variable as you go; the algorithm form exists precisely so that this produces one unambiguous answer. When a step says "let," it is binding a name; when it says "if," it is a branch you take or skip; when it says "for each," it is a loop with the body indented beneath it; when it says "return" or "throw," the algorithm stops there and nothing after it runs. That small grammar covers most of what you will meet.

The other thing to respect is that the hyperlinked terms inside steps are terms of art, not casual English. A linked phrase like "valid," "entries," or "in parallel" has a precise definition elsewhere in the spec or in a referenced one; follow the link rather than assuming the everyday meaning, because the everyday meaning is exactly where the bugs hide. "In parallel," for instance, has a specific concurrency meaning in web specs that is not the colloquial one, and an algorithm that hands work off "in parallel" and resumes later behaves nothing like a naive reading suggests. The discipline is to treat every linked term as a function call into another definition: you do not have to read that definition in full every time, but you do have to know it is not the dictionary word, and you do have to follow it when the behavior turns on it.

WebIDL rewards the same per-marker reading. Beyond nullability and readonly, the markers that recur and change meaning are worth recognizing on sight: optional arguments and their defaults tell you what happens when a caller omits them, a Promise return type tells you the operation is asynchronous before you read a word of prose, sequence<T> versus an array type tells you the exact collection contract, and an [Exposed=...] extended attribute tells you which global the interface even exists on — getting that last one wrong is why code works in a document and throws in a worker. You do not need the whole WebIDL grammar memorized; you need the dozen markers that carry meaning, and the WebIDL specification itself is the place to resolve the one you do not recognize rather than guessing from the name.

A repeatable reading procedure

The point of all of this is that it composes into a routine you can run on any specification, from any body, without rediscovering the approach each time:

  • Identify the owning body and the document's maturity, so you know which process and expectations apply.
  • Read the status / conformance section first — what is normative, how the requirement keywords are interpreted, what stability the document claims.
  • Locate the normative section for the feature; ignore notes and examples for correctness, use them only for understanding.
  • Read the WebIDL block before the prose to get the exact surface — types, nullability, what is read-only, what is async.
  • Trace the relevant algorithm one numbered step at a time; follow hyperlinked terms to their definitions instead of guessing.
  • Check the open issues and the edit history for the section — unresolved discussion is information about how settled the text is.

That last step matters more than it looks. When the specification and the behavior you observe in an engine disagree, the gap is not noise — it is a signal about maturity and about a specific vendor's position, and reading it correctly is its own discipline owned by separate articles on this topic. The same is true of staying current: a spec you read once is a snapshot of a moving document, and keeping it under watch after the first read is a routine this topic owns elsewhere. Reading the spec confidently is the foundation those depend on, and it does not, by itself, tell you the feature is safe to ship — that judgment is a distinct axis with its own article. What this skill gives you is the ability to stop relying on the summary and check the source, which is the prerequisite for every other decision within this topic.

Project Inquiry