1<h1>Menu</h1>2<span>Tea</span>3<span>Cake</span>4<p>Open daily.</p>window 280pxbody 264pxwindow 360pxbody 344px1span {2 display: inline;3 width: auto;4}5h1 { display: block; }MenuTeaCakeOpen daily.<h1><span><span><p>150pxblockinline-blocknone
Left: the two files, index.html and style.cssRight: the page body and one box per element, laid out in normal flowTokens: the tags and each new CSS value on their way to the boxesLeft: the HTML file (four elements in source order) and the stylesheet. Right: the page body seen from above, its top at the back, with one box per element. Block boxes (h1, p) each take a whole line; inline boxes (the spans) share a line and are as wide as their words. Changing display re-flows the same boxes: block, inline-block, none. A narrower window re-flows them again. The page drawing leaves out the margins browsers put above and below h1 and p, and draws every line the same height, so the order is easy to see. Widths in the labels are the real used widths; the two inline boxes are drawn wider than their words so the words fit.

Normal flow

  1. Layout means deciding where boxes go. The browser makes one rectangular box for each element here: h1, two spans and p. With no layout rules it places them in normal flow: in source order, by each box's display type.

Changing display

Every screen size

What happens

;; step 1/8 · boxes
index.html, inside <body>, in source order:
  <h1>   "Menu"        display: block
  <span> "Tea"         display: inline
  <span> "Cake"        display: inline
  <p>    "Open daily." display: block
style.css only states the defaults so far,
so it changes nothing yet

The page drawing leaves out the margins browsers put above and below h1 and p, and draws every line the same height, so the order is easy to see. Widths in the labels are the real used widths; the two inline boxes are drawn wider than their words so the words fit. Strictly, the two inline spans sit between two block boxes, so the browser wraps their line in an anonymous block box of its own (CSS 2.2, section 9.2.1.1). It changes nothing you can see here.