liveBook · Manning

Border

As explained in Web Design Playground, Second Edition

A CSS border is the edge region surrounding an element's content and padding, which can be rendered as lines around the element box.

A CSS border is the optional line around an element’s padding. It separates enclosed content from nearby content and forms the outer edge before the margin begins. section 9.4 section 9.1

Think of an element as a box: content sits inside padding, the border wraps the padding, and margin leaves space outside the border. Together, these parts form the CSS box model. section 9.1 section 9.7

Build a basic border with the three-part shorthand:

  • Write border: width style color. section 9.7
  • Choose a width such as 1px, or use thin, medium, or thick. section 9.4
  • Choose a style such as solid, dotted, dashed, double, groove, ridge, inset, outset, hidden, or none. section 9.4
  • Choose a color using a CSS color name. section 9.4

A simple pullquote border

.pullquote { border: 1px solid black; } This gives the pullquote a thin, solid, black line around it. section 9.4

Bordering a navigation menu

A list can use the same shorthand to make the navigation area look like one self-contained section: ul { border: 1px solid black; padding-top: .75em; padding-bottom: .75em; list-style-type: none; text-align: center; text-transform: uppercase; }

Figure 9.1 The main parts of an element box

Use the element-box diagram to see how the border sits between padding and margin. section 9.1

How Web Design Playground, Second Edition covers it

How deep it goes
Explains box-model placement, shorthand syntax, widths, styles, colors, and examples, but defers detailed border-side properties.
Examples
Demonstrates a bordered pullquote, a bordered navigation list, and borders used as alternatives to horizontal rules.
What it assumes
Assumes basic HTML and CSS use while teaching the element box, box-model parts, and border syntax as foundations.
What you can do after
Build it from scratch by applying border shorthand to separate content and create visible sections.
How it connects
Connects borders with the CSS box model, content, padding, margin, outline, width, height, and visual separation.

Also explained in

Compare how 5 books explain border →

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.