Back to all projects

Case study

Rusty Engine

A bare-bones browser engine in Rust that parses and styles basic HTML and CSS. Built to learn how the web actually works, from the document tree up.

Role
Personal project
Period
2020-09 → 2021-01
Status
Shipped
Tags
4
RustHTML parserCSS parserBrowser internals

Summary

A toy HTML and CSS engine in Rust. Parses a small subset of HTML into a DOM, parses a small subset of CSS, and does the style cascade by hand.

What I built

  • An HTML parser that walks a small subset of the spec and produces a DOM tree.
  • A CSS parser and a hand-rolled style cascade that resolves rules into computed styles per node.

What was hard

The style cascade. Reading a CSS rule is easy; deciding which rule wins on a given node, in what order, with what specificity, and how inheritance fills in the gaps is where the project lived.

What's next

The engine is a learning project, not a browser. It will stay small on purpose; the point was never to ship a browser.

What I learned

Probably the project that taught me the most per line of code. Most of what happens between <html> and a painted pixel was a black box to me before this, and it stopped being one after.