The Browser
A browser is four programs in a sequence, and you can understand each program alone. Bytes become a tree. A stylesheet decides the appearance of each node. The tree becomes rectangles with positions, and the rectangles become pixels. The script engine at the end is the language from an earlier section of this track, applied to a document.
- By design, HTML has no parse errors. Each malformed document has a defined tree. The reason is that the first browsers had to render the web that already existed.
- A void element is complete by itself. If the parser treats
<br>as an unclosed tag, the parser puts the rest of the page inside the<br>. - Layout is two passes, not one. Widths go from the parent to the children. Heights are the sum of the children.
- The cascade is a sort: first by specificity, then by order. The last rule wins.
6 chapters.
- An HTML ParserA format with no parse errors, because the first browsers made that decision.
- A Stylesheet and the CascadeTo match a rule is easy. The cascade is the decision about which match wins.
- LayoutThe parent gives each child its width. The children add up to the height of the parent.
- PaintA rectangle of memory, filled from back to front. The last write wins.
- A Scripting EngineThe language knows nothing about documents. The host makes the connection between them.
- The Whole PipelineBytes, tree, styles, boxes, pixels. Five stages, in one direction.