A web browser built in Rust! It currently supports a subset of HTML and CSS when rendering, as well as UI elements like tabs. The goal of this project is to learn more about how browsers work under the hood and to improve my Rust skills, as such it contains a few dependencies but is otherwise built from scratch.
Warning
This is a work in progress and is not intended for production use. It is missing many features and is not optimized for performance or security.
- Headless mode
- Navigating to URLs
- Cookies
- UI theming with user configurable TOML file
- Tabbed browsing
Supported CSS properties can be found: ./docs/CSS.md.
https://github.com/andre-eriksson
https://flask.palletsprojects.com/en/stable/quickstart
https://en.wikipedia.org/wiki/Web_browser
The browser is composed of 7 subsystems, each responsible for a specific aspect of the browser's functionality.
- IO Subsystem: Responsible for handling all input/output operations, including file system access and network communication.
- HTTP Client: Responsible for making HTTP requests and handling responses.
- HTML Parser: Parses HTML documents and builds the DOM tree.
- Tokenizer: Breaks HTML into tokens.
- DOM Builder: Builds the DOM tree from tokens.
- CSS Parser: Parses CSS stylesheets and builds the CSSOM.
- Tokenizer: Breaks CSS into tokens.
- CSSOM Builder: Builds the CSS Object Model from tokens.
- Layout Engine: Generates the layout tree based on the DOM and style tree.
- Selector Generation: Converts CSSOM to selectors that can be applied to the DOM.
- Styletree Builder: Combines CSS selectors, and DOM to create the style tree.
- Rendering Engine: Renders the layout tree to the screen using GPU acceleration.
- Kernel (Browser Core): Manages the overall browser state, including tabs, navigation, and communication between subsystems.
- UI Layer: Manages the user interface elements like tabs, address bar, etc.
- History management
- Bookmarks
- Download manager
- Form handling
- JavaScript support
- Advanced CSS features (animations, flexbox, grid, etc.)
- Advanced security features (sandboxing, etc.)
- Extensions or plugins
- Spec compliance with all web standards
- Install Rust (https://www.rust-lang.org/tools/install)
- Run
# Standard mode
$ cargo run
# Help for command line options
$ cargo run -- --help
# Headless mode
$ cargo run -- --headless
# Start with a specific URL
$ cargo run -- --url http://localhost:5000/preview.htmlThe project includes unit tests for many subsystems. To run the tests, use the following command:
$ cargo test
# Specific crate tests
$ cargo test -p <crate-name>This project intentionally uses a limited set of dependencies, the goal for this project is to minimize relying on external libraries for core functionality, but I am also realistic about what can be achieved in a reasonable timeframe.
Rust crates dependencies are chosen based on the following criteria:
- Essential functionality that would be impractical to implement from scratch and is out of scope for this project (e.g.,
wgpufor GPU rendering). - Development and testing tools that do not impact the core functionality of the browser (e.g.,
tracingfor logging). - Libraries that would force me to work extensively on other aspects that isn't browser related (e.g.,
serdefor serialization/deserialization). - Temporary dependencies that facilitate developer velocity, these fall into two sub-categories:
- Dependencies that will be replaced by a lower-level dependency eventually (e.g.,
reqwestfor HTTP requests, which could eventually be replaced bycurl/libcurl). - Dependencies that come from another dependency but are used for convenience and will be removed when that dependency is removed (e.g.,
cosmic-textfor text shaping, which is a dependency oficed).
- Dependencies that will be replaced by a lower-level dependency eventually (e.g.,
To generate the most up-to-date list, run the gen_third_party.py script and/or refer to the Cargo.toml file and each individual subsystem crate's Cargo.toml, e.g., crates/errors/Cargo.toml.
This project relies on some external tools and libraries, these are not dependencies of the browser itself but are used to facilitate development and testing.
- Python 3 - Required to run the Flask server and other scripts.
- Flask - Used for serving test HTML files, allows us to test internal functionality outside of rendering such as cookies, headers, etc.
We have fallback fonts to ensure that the browser can always render text properly, these can be found in: ./assets/font, licenses for these fonts can be found in FONTS.md.
Currently included fonts:
- OpenSans (SIL Open Font License)
- Roboto Mono (SIL Open Font License)
This project is licensed under the MIT License - see the LICENSE file for details.


