liveBook · Manning

Element box

As explained in Web Design Playground, Second Edition

An element box is the rectangular layout box generated for an HTML element, consisting of content, padding, border, and margin areas.

Every HTML element sits inside an invisible rectangle. CSS lets you control that rectangle’s size, spacing, borders, and position—an idea that makes page layout much less mysterious. section 9.1

Figure 9.1 The main parts of an element box

Use the diagram to see the element box from the inside out: content, padding, border, and margin. section 9.1

The box has four main parts:

  • Content holds text, images, or other material. section 9.1
  • Padding adds breathing room between the content and border. section 9.3
  • Border surrounds the content and padding with lines. section 9.1
  • Margin adds space outside the border, separating the element from nearby elements. section 9.7

Browsers calculate block-level boxes automatically: width usually follows the container, while height grows to fit the content. Set width and height when you need control, but let text create its own height whenever possible. section 9.2

Give a navigation menu room to breathe

Turning list items into inline blocks keeps them in a row. Adding padding separates labels such as Home, Research Papers, Blog, and Contact Info so they do not run together. section 9.3

How Web Design Playground, Second Edition covers it

How deep it goes
Defines four box areas and demonstrates sizing and padding, while treating borders and margins mainly through summary syntax.
Examples
Uses diagrams, a padded navigation bar, inline-block list items, and a long text block to show box behavior.
What it assumes
Assumes basic HTML elements and CSS declarations while explaining box parts and browser sizing defaults from the ground up.
What you can do after
Apply it via CSS properties to size boxes, add spacing, and improve navigation readability.
How it connects
Connects element boxes with the CSS box model, width, height, padding, borders, margins, display, and block-level elements.

Also explained in

Compare how 2 books explain element box →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground, Second Edition. The section links point to the parts of the book it draws on.