Measure a Card with Linked and Independent CSS Borders
Admin ·
A numerical example makes the layout cost of a border easy to spot. Use the 144 × 76 px card, then compare one shared border with a sample that leaves the right edge open.
Measure a card with four linked dashed edges
With Link all edges checked, set Border width to 6 px, Border style to Dashed and Border color to rebeccapurple. The exported shorthand uses rgb(102, 51, 153).
Set Box sizing to Content box. Two 6 px borders add 12 px to each axis, so the reported size is 156 × 88 px. Switch to Border box to return the outer dimensions to 144 × 76 px.
CSS Backgrounds and Borders Level 3 line styles, widths and rounded cornersCSS Box Sizing Level 3 box-sizing
Open the right edge and style the other three
Uncheck Link all edges and set Corner radius to 0 px to make the changes easy to inspect. Use the Physical edge control to set each line. The color choices are #943318 for Top, #2d6b60 for Bottom and #234c50 for Left.
With Content box selected, the 4 px left stroke and open right edge add 4 px to the width. The top and bottom add 13 px to the height, producing 148 × 89 px.
| Side | Entered width | Line style | Space in the box |
|---|---|---|---|
| Top | 8 px | Solid | 8 px |
| Right | 7 px | None | 0 px |
| Bottom | 5 px | Dotted | 5 px |
| Left | 4 px | Double | 4 px |
CSS Backgrounds and Borders Level 3 line styles, widths and rounded cornersCSS Box Sizing Level 3 box-sizing
Apply the generated edge declarations
Download the CSS and apply the border-sample class to the destination box. Compare its dimensions under the same content size, padding and box sizing.
The declarations use physical sides. A left accent keeps its position when text direction changes. Use a logical border property in your stylesheet if the accent should follow the writing direction.
CSS Backgrounds and Borders Level 3 line styles, widths and rounded cornersCSS Logical Properties Level 1 flow-relative borders
Common questions
Why is the right border’s measured width zero even with 7 px entered?
The browser computes the border width as zero for a none or hidden border style. The stylesheet can retain your entered width for a later style change.
Will a new radius keep all sides visible the same distance from the corner?
Browsers join adjacent widths and styles along the corner curve. Start with radius zero to verify individual side values, then increase the radius to suit your layout.