Module 14 · From Scratch · Systems from scratch · about 16 min to read
Continue where you left off ×
A browser engine of your own
Capstone Keypress to Pixel · Open board
The board that follows one key press until a pixel changes colour. A browser engine does the same last step for a whole page: it turns text into a grid of coloured pixels.
The idea in 30 seconds
An HTML parser turns text into a tree of elements, called the DOM.
A CSS rule is a selector plus settings, and the selector says which elements it covers.
When rules disagree, the one with the higher specificity wins, and a tie goes to the later rule.
The style tree is the DOM with every node’s final settings attached.
Layout gives every box an x, y, width and height, by stacking blocks and subtracting margin and padding.
Paint fills each box’s rectangle in order, parent first, and the file is just the grid of pixels.
Read the story
Lesson 113 of 117 in From Scratch
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year .
See plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson The problem: a web page is text, a screen is pixels HTML becomes the DOM: a tree of elements CSS rules and selectors: which boxes does a rule talk about? Specificity: when two rules disagree, one must win The style tree: every node with its final settings The layout box: where does each box go? Paint: fill each box with its colour The code Run it Break it: a tag with no closing tag What this leaves out Terms it explains: tag, DOM, rules, selector, specificity, style tree, box.
Review From Scratch
Mark as read Saved in this browser, and to your account when you sign in.