Web Browser Engineering

Pavel Panchekha

Web browsers are ubiquitous, but how do they work? This book explains, building a basic but complete web browser, from networking to JavaScript, in a thousand lines of Python.

This book is a work in progress. Use at your own risk.


  1. Preface

  2. Preliminaries

Part 1: Drawing Graphics

  1. Downloading Web Pages
    URLs and HTTP requests
  2. Drawing to the Screen
    Creating windows and drawing to a canvas
  3. Formatting Text
    Line wrapping and word spacing

Part 2: Viewing Documents

  1. Constructing a Document Tree
    Parsing and fixing HTML
  2. Laying Out Pages
    Inline and block layout, plus the box model
  3. Applying User Styles
    Parsing and applying CSS
  4. Handling Buttons and Links
    Hyperlinks and browser chrome

Part 3: Running Applications

  1. Sending Information to Servers
    Form submission and web servers
  2. Running Interactive Scripts
    Changing the DOM and reacting to events
  3. Saving Partial Layouts
    Two-phase layout and fast rendering
  4. Keeping Data Private
    Cookies and logins, XSS and CSRF


  1. What Wasn’t Covered

  2. A Changing Landscape