CSS borders, outline, and radius

Quick reference for CSS borders, border-radius, and outline, including layout size and focus visibility.

A border is part of the box. With the default box-sizing: content-box, border width adds to the used outer size; with border-box it is included in width and height, as the box-model page already calculates. This page does not repeat those sums.

outline is not a border. It is drawn outside the border edge, does not take up layout space, and does not change the used width or height. It is the usual focus-visible ring on buttons and links. Do not set outline: none (or a zero outline) unless you provide an equally visible focus style.

Whether outline follows border-radius has improved in current browsers but was historically inconsistent. Treat that as a compatibility limit; this page does not claim a measured result for every engine.

Examples were parsed for syntax and structure. Focus rings and layout sizes were not measured in a browser.

Official sources: MDN and the CSS specification. Fragments were checked with PostCSS 8 for syntax and structure. That is not a CSS conformance suite, and this is not a browser render or visual test.

CSS reference catalog → · CSS tutorial overview →

Border style, width, color, and radius

The initial border-style is none, so setting only border-width or border-color often paints nothing. A visible border needs a style other than none or hidden, for example solid, dashed, or dotted. border-radius curves the border box (and the background clip) but does not by itself create a circular hit area in every context.

Syntax or propertyInitial / defaultInheritedApplies toNotes
border-stylenonenoall elementsCommon values: none, hidden, solid, dashed, dotted, double. none and hidden prevent a border from being painted (hidden also affects table border conflict resolution). Style must be set for a width to show.
border-widthmediumnoall elementsCommon values: thin, medium, thick, or a length such as 1px or 0.125rem. It has no visible effect while the style is none. On content-box it adds to the used size.
border-colorcurrentColornoall elementsAny color, including currentColor. The initial currentColor means the border follows the text color unless you override it.
bordersee longhandsnoall elementsShorthand for width, style, and color. At least a style is required for a visible border. One, two, three, or four sides can also use border-top and friends.
border-radius0noall elementsCorner radii as lengths or percentages. Percentages are relative to the corresponding side of the border box. Large radii can make the curve meet and produce a pill or ellipse. This is not an outline property.

Outline size, offset, and focus visibility

outline-style, outline-width, outline-color, and outline-offset describe a line that does not affect box-sizing arithmetic. Two boxes with the same width, padding, and border stay the same used size if one of them also has a 4px outline. A 4px border would not.

For keyboard focus, prefer :focus-visible with a visible outline (and an offset when you need a gap from the border) rather than removing the outline on :focus for everyone. A custom ring is fine; an invisible focus state is not.

Syntax or propertyInitial / defaultInheritedApplies toNotes
outline-stylenone (auto on some focused user-agent controls)noall elementsCommon values: none, solid, dashed, auto. auto lets the user agent draw its focus outline. none hides the outline and should not be used on :focus without a replacement.
outline-widthmediumnoall elementsA length or keyword, like border-width, but it does not change the used width or height of the box.
outline-colorauto (often currentColor in practice)noall elementsAny color, or auto. auto may use a platform highlight color. invert is a historical value and is not reliable as a compatibility assumption.
outline-offset0noall elementsSpace between the border edge and the outline. A positive length pushes the outline outward. It also does not affect layout size.
outlinesee longhandsnoall elementsShorthand for width, style, and color. outline-offset is a separate property and is not reset by a three-value outline shorthand in the usual way — set it explicitly when you need a gap.

A border and a non-layout outline, plus a focus-visible ring

border: 2px solid #0B5853;
border-radius: 8px;
outline: 2px dashed #1B1814;
outline-offset: 4px;

The border participates in the box. The outline is offset outside it and does not add to used width. A button keeps a visible :focus-visible ring.

  • No outline: none appears on :focus. Whether the dashed outline follows the 8px radius is a compatibility limit and was not measured here.
html
<div class="box">Border, radius, and outline</div>
<button type="button" class="action">Focusable control</button>
<style>
.box {
  width: 16rem;
  padding: 0.75rem;
  border: 2px solid #0B5853;
  border-radius: 8px;
  outline: 2px dashed #1B1814;
  outline-offset: 4px;
  font-family: sans-serif;
}
.action {
  margin-top: 1rem;
  font: inherit;
  border: 2px solid #0B5853;
  border-radius: 8px;
  background: #ffffff;
}
.action:focus-visible {
  outline: 2px solid #0B5853;
  outline-offset: 2px;
}
</style>

What this markup means

.box has a 2px border, which is part of its box, and a dashed outline 4px outside that border, which is not part of its used width. The button uses the same radius and keeps a 2px solid outline on :focus-visible instead of removing focus visibility. box-sizing is left at its initial content-box; see the box-model page for width arithmetic.

Related: Box model, Colors

MDN documentation → · CSS specification →