Lesson 1 · Unit 02
Two trees
HTML becomes the DOM, CSS becomes the CSSOM, and only some nodes get a box
What you practise
- HTML parsed into a tree, CSS into another, the render tree that joins them, what
display: noneremoves
Try a question from this lesson
Pick one
Neither paragraph is closed. What does the browser build from this?
<p>One
<p>TwoCorrect answer
Two p elements, one after the other
Why
The HTML parser never fails. It has a rule for every mistake, and here the rule is that a paragraph cannot hold a paragraph, so the second <p> closes the first. What you get is decided by those rules, not by your indentation.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
The DOM
The browser does not keep your HTML as text. It parses it into a tree of nodes: the DOM.
Every element is a node, and so is every run of text. Scripts and styles work on this tree, never on the file.
<ul>
<li>Tea</li>
<li>Milk</li>
</ul>
ul
li
"Tea"
li
"Milk"Concept
The CSSOM
CSS gets a tree of its own: the CSSOM, every rule from every stylesheet.
For each node the browser finds all the rules that match and lets the strongest win. When two are equally strong, the later one wins. So no style is final until all the CSS is in.
10 more exercises in the app
- 4× type the answer
- 3× multiple choice
- 1× true or false
- 1× order the lines
- 1× fill the blanks
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.