web/html-tags-how-angle-brackets-become-a-tree-in-your-browser.md

HTML tags: how angle brackets become a tree in your browser

The web · 13 min read ·

Every web page is plain text with labels in angle brackets: HTML tags. An opening tag, some content and a closing tag make an element, and attributes like href add settings.

Tags nest inside each other, and there's one golden rule: close them in the reverse order you opened them. The browser reads all of it and builds a tree called the DOM, quietly repairing your mistakes along the way, sometimes in surprising ways.

Try it in a live editor with a tree view, then spot the broken nesting yourself.