⚡ Zig Guide LiveUnofficialbut fully verified
✓ Zig 0.17.0-dev.1516+8a4b5424dWhat's newOn an older Zig?

The Browser

A browser is four programs in a row, and each one is understandable on its own. Bytes become a tree, a stylesheet decides what each node looks like, the tree becomes rectangles with positions, and the rectangles become pixels. The scripting engine at the end is the language built earlier in this track, pointed at a document.

  1. HTML has no parse errors by design. Every malformed document has a defined tree, because the browsers that shipped first had to render the web that already existed.
  2. A void element is complete on its own. Treating <br> as an unclosed tag swallows the rest of the page.
  3. Layout is two passes, not one: widths flow down from the parent, heights add up from the children.
  4. The cascade is a sort. Specificity, then order, and the last rule standing wins.

6 chapters.

  • An HTML ParserA format with no parse errors, because the browsers that shipped first decided so.
  • A Stylesheet and the CascadeMatching is easy. Deciding which match wins is what cascading means.
  • LayoutWidths flow down from the parent. Heights add up from the children.
  • PaintingA rectangle of memory, filled back to front. The last write wins.
  • A Scripting EngineThe language knows nothing about documents. The host is what connects them.
  • The Whole PipelineBytes, tree, styles, boxes, pixels. Five stages, in one direction.