Browsers work by parsing HTML and CSS to construct a DOM and render tree, laying out elements and painting them to the screen. The main components are the user interface, browser engine (which handles networking, JavaScript interpretation, etc.), and rendering engine. The rendering engine constructs the DOM from HTML and CSSOM from CSS, builds the render tree by combining them, then lays out and paints elements to display the final webpage. Optimization focuses on minimizing critical resources, path length, and bytes to speed up the initial render.