How to use this playground
This page runs the exact same pipeline as the Rust engine, reimplemented in JavaScript for teaching: HTML becomes a DOM tree, CSS becomes a stylesheet, the two are combined into computed styles, and those are laid out into boxes and painted onto the canvas. Everything updates as you type.
The controls
- HTML editor. Type markup on the left. The parser handles nesting, attributes, void elements like
<br>, and implicit closing like a bare<li>. - CSS editor. Type rules on the right. Selectors can use a tag, a
.class, an#id, or a combination. The cascade uses specificity then source order. - DOM tree panel. Shows the parsed tree. Click any node to select it.
- Computed styles panel. Shows the cascaded and inherited values for the selected node, plus its box model numbers.
- Rendered boxes canvas. Draws the laid out boxes. Toggle Show box edges to overlay margin, border, padding, and content like browser devtools. The selected node is outlined.
A short guided tour
- Look at the DOM tree. Notice how nesting in the HTML editor becomes parent and child nodes.
- Click the
<h1>node. The Computed styles panel fills in. See howcolorwas inherited whilefont-sizecame from a rule. - In the CSS editor, change
.cardwidth to240px. Watch the canvas reflow instantly. - Turn on Show box edges. The orange band is margin, yellow is border, green is padding, blue is content.
- Add a rule like
p { color: crimson; }and then a stronger one,#lead { color: teal; }, on the lead paragraph. The higher specificity id wins. That is the cascade.
every number above is computed by the in-browser engine on this page, the same pipeline as the Rust CLI. Nothing is sent anywhere.