Borders, corners & outlines

The properties that draw a box's border, round or reshape its corners, replace the border with an image, and draw an outline outside it. The logical border properties (border-block-start, border-inline-end-color, border-start-end-radius and so on) are here too: each maps to a physical side or corner according to the element's writing-mode and direction, so in left-to-right horizontal text block-start is the top and inline-start is the left. Padding and margin are under Box model, box-shadow under Filters, effects & masking, and border-collapse and border-spacing under Lists, tables & content.

Border shorthands

border

Sets the width, style and colour of all four borders at once. Any part left out is reset to its initial value, so border: 2px solid gives a currentcolor border.

Syntax<line-width> || <line-style> || <color>
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
AnimationSee individual properties
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-borders-4

The four sides always get the same value. border also resets border-image to its initial value, so declare any border image after it.

border: 1px solid color-mix(in oklch, currentcolor 20%, transparent);
A thin, faint border that follows the text colour.

border-top, border-right, border-bottom, border-left

Set the width, style and colour of the border on one physical side.

Syntax<line-width> || <line-style> || <color>
InitialSee individual properties
Applies toAll elements except ruby base containers and ruby annotation containers
InheritedNo
AnimationSee individual properties
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-borders-4

border-block-start, border-block-end, border-inline-start, border-inline-end

Set the width, style and colour of the border on one flow-relative side. In left-to-right horizontal text these are the top, bottom, left and right borders.

Syntax<line-width> || <line-style> || <color>
InitialSee individual properties
Applies toAll elements except ruby base containers and ruby annotation containers
InheritedNo
AnimationSee individual properties
SupportChrome 69 · Firefox 41 · Safari 12.1
Speccss-borders-4
border-inline-start: 4px solid var(--accent);
A rule on the side where lines begin: left in English, right in Arabic or Hebrew.

border-block, border-inline

Set the same width, style and colour on both borders in one axis: border-block sets block-start and block-end, border-inline sets inline-start and inline-end.

Syntax<'border-block-start'>
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
AnimationSee individual properties
SupportChrome 87 · Firefox 66 · Safari 14.1
Speccss-borders-4

border-color

Shorthand for the colours of the four physical borders. One value sets all four sides; two set top/bottom then left/right; three set top, left/right, bottom; four go clockwise from the top.

Syntax[ <color> | <image-1D> ]{1,4}
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
AnimationSee individual properties
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-borders-4

border-style

Shorthand for the line style of the four physical borders, taking one to four values in the same order as border-color. A border is only drawn when its style is something other than none or hidden.

Syntax<'border-top-style'>{1,4}
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
AnimationSee individual properties
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-borders-4
ValueEffect
noneNo border. The border width computes to 0.
hiddenLike none, but in a table with collapsed borders it suppresses any border it meets.
solidA single solid line.
dottedA row of round dots.
dashedA row of short dashes.
doubleTwo parallel solid lines. The two lines and the gap between them add up to the border width.
grooveLooks carved into the page, using two shades of the border colour.
ridgeThe opposite of groove: looks raised out of the page.
insetMakes the whole box look pressed into the page.
outsetThe opposite of inset: makes the box look raised.

border-width

Shorthand for the thickness of the four physical borders, taking one to four values in the same order as border-color.

Syntax<'border-top-width'>{1,4}
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
AnimationSee individual properties
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-borders-4

border-block-color, border-inline-color

Set the colours of both borders in one flow-relative axis. One value sets both sides; two set the start side then the end side.

Syntax<'border-top-color'>{1,2}
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
AnimationSee individual properties
SupportChrome 87 · Firefox 66 · Safari 14.1
Speccss-borders-4

border-block-style, border-inline-style

Set the line styles of both borders in one flow-relative axis. One value sets both sides; two set the start side then the end side.

Syntax<'border-top-style'>{1,2}
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
AnimationSee individual properties
SupportChrome 87 · Firefox 66 · Safari 14.1
Speccss-borders-4

border-block-width, border-inline-width

Set the thickness of both borders in one flow-relative axis. One value sets both sides; two set the start side then the end side.

Syntax<'border-top-width'>{1,2}
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
AnimationSee individual properties
SupportChrome 87 · Firefox 66 · Safari 14.1
Speccss-borders-4

Border colour, style & width longhands

border-top-color, border-right-color, border-bottom-color, border-left-color

The colour of the border on one physical side. The initial currentcolor means a border with no colour set matches the text.

Syntax<color> | <image-1D>
Initialcurrentcolor
Applies toAll elements except ruby base containers and ruby annotation containers
InheritedNo
AnimationBy computed value
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-borders-4

border-block-start-color, border-block-end-color, border-inline-start-color, border-inline-end-color

The colour of the border on one flow-relative side.

Syntax<color> | <image-1D>
Initialcurrentcolor
Applies toAll elements except ruby base containers and ruby annotation containers
InheritedNo
AnimationBy computed value
SupportChrome 69 · Firefox 41 · Safari 12.1
Speccss-borders-4

border-top-style, border-right-style, border-bottom-style, border-left-style

The line style of the border on one physical side. The values are listed under border-style.

Syntax<line-style>
Initialnone
Applies toAll elements except ruby base containers and ruby annotation containers
InheritedNo
AnimationDiscrete
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-borders-4

border-block-start-style, border-block-end-style, border-inline-start-style, border-inline-end-style

The line style of the border on one flow-relative side.

Syntax<line-style>
Initialnone
Applies toAll elements except ruby base containers and ruby annotation containers
InheritedNo
AnimationDiscrete
SupportChrome 69 · Firefox 41 · Safari 12.1
Speccss-borders-4

border-top-width, border-right-width, border-bottom-width, border-left-width

The thickness of the border on one physical side: a non-negative length, or one of the keywords thin (1px), medium (3px) and thick (5px).

Syntax<line-width>
Initialmedium
Applies toAll elements except ruby base containers and ruby annotation containers
InheritedNo
AnimationBy computed value
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-borders-4

The width computes to 0 while the matching style is none or hidden, which is why border-width: 2px on its own draws nothing.

border-block-start-width, border-block-end-width, border-inline-start-width, border-inline-end-width

The thickness of the border on one flow-relative side.

Syntax<line-width>
Initialmedium
Applies toAll elements except ruby base containers and ruby annotation containers
InheritedNo
AnimationBy computed value
SupportChrome 69 · Firefox 41 · Safari 12.1
Speccss-borders-4

Border radius

border-radius

Shorthand for the four physical corner radii. Values go clockwise from the top-left corner, with one to four values filled in the same way as margin. A slash separates the horizontal radii from the vertical radii, for elliptical corners.

Syntax<length-percentage [0,∞]>{1,4} [ / <length-percentage [0,∞]>{1,4} ]?
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
PercentagesRefer to the corresponding dimension of the border box
AnimationSee individual properties
SupportChrome 4 · Firefox 4 · Safari 5
Speccss-borders-4

The rounding clips the background, and also the content when overflow is not visible. If neighbouring radii add up to more than the side they share, all the radii are scaled down until they fit, which is why a very large value such as 999px gives a pill shape.

border-radius: 50%;           /* a circle, if the box is square */
border-radius: 1rem 1rem 0 0;   /* round the top corners only */
border-radius: 2rem / 1rem;     /* elliptical corners */
Three common forms of the shorthand.

border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius

The radius of one physical corner. One value gives a circular corner; two give the horizontal then the vertical radius of an elliptical corner.

Syntax<border-radius>
Initial0
Applies toAll elements, except table elements when border-collapse is collapse
InheritedNo
PercentagesRefer to the corresponding dimension of the border box
AnimationBy computed value
SupportChrome 4 · Firefox 4 · Safari 5
Speccss-borders-4

border-start-start-radius, border-start-end-radius, border-end-start-radius, border-end-end-radius

The radius of one flow-relative corner. The first word is the block side and the second the inline side, so in left-to-right horizontal text border-start-end-radius is the top-right corner and border-end-start-radius the bottom-left.

Syntax<border-radius>
Initial0
Applies toAll elements, except table elements when border-collapse is collapse
InheritedNo
PercentagesRefer to the corresponding dimension of the border box
AnimationBy computed value
SupportChrome 89 · Firefox 66 · Safari 15
Speccss-borders-4

Corner shapes

corner-shape

Shorthand for the shape of the four physical corners, clockwise from the top-left. It changes the curve drawn inside the area that border-radius sets aside, so it has no visible effect on a corner whose radius is 0. The border, background, shadow and outline all follow the new shape.

Syntax<'corner-top-left-shape'>{1,4}
Initialround
Applies toAll elements where border-radius can apply
InheritedNo
AnimationSee individual properties
SupportChrome 139 · Firefox no · Safari no
Speccss-borders-4
ValueEffect
roundAn ordinary elliptical curve, the same as having no corner-shape. Equal to superellipse(1).
squircleA curve between round and square. Equal to superellipse(2).
squareA square corner, as if the radius were 0. Equal to superellipse(infinity).
bevelA straight diagonal cut across the corner. Equal to superellipse(0).
scoopA concave curve, the inverse of round. Equal to superellipse(-1).
notchA square notch cut into the corner. Equal to superellipse(-infinity).
superellipse(K)Any curve in that range: positive numbers bulge outwards, 0 is a straight line, negative numbers curve inwards.
border-radius: 2rem;
corner-shape: squircle;
Smoother, more square-shouldered corners than a plain radius. Browsers without support show ordinary round corners.

corner-top-shape, corner-right-shape, corner-bottom-shape, corner-left-shape

Set the shape of the two corners on one physical side. One value sets both corners; two set them in order (left then right for the top and bottom sides, top then bottom for the left and right sides).

Syntax<'corner-top-left-shape'>{1,2}
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
AnimationSee individual properties
SupportChrome 139 · Firefox no · Safari no
Speccss-borders-4

corner-block-start-shape, corner-block-end-shape, corner-inline-start-shape, corner-inline-end-shape

Set the shape of the two corners on one flow-relative side. One value sets both corners; two set the start corner then the end corner along that side.

Syntax<'corner-top-left-shape'>{1,2}
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
AnimationSee individual properties
SupportChrome 139 · Firefox no · Safari no
Speccss-borders-4

corner-top-left-shape, corner-top-right-shape, corner-bottom-right-shape, corner-bottom-left-shape

The shape of one physical corner. The values are listed under corner-shape.

Syntax<corner-shape-value>
Initialround
Applies toAll elements where border-radius can apply
InheritedNo
AnimationAs superellipse() values; keywords are converted to their superellipse() equivalents first
SupportChrome 139 · Firefox no · Safari no
Speccss-borders-4

corner-start-start-shape, corner-start-end-shape, corner-end-start-shape, corner-end-end-shape

The shape of one flow-relative corner. As with the logical radii, the first word is the block side and the second the inline side.

Syntax<corner-shape-value>
Initialround
Applies toAll elements where border-radius can apply
InheritedNo
AnimationAs superellipse() values; keywords are converted to their superellipse() equivalents first
SupportChrome 139 · Firefox no · Safari no
Speccss-borders-4

Border image

border-image

Shorthand that draws an image in the border area in place of the border styles. The image is cut into nine pieces: four corners, four edges and a middle. The corners go in the border's corners and the edges are stretched or tiled along its sides.

Syntax<'border-image-source'> || <'border-image-slice'> [ / <'border-image-width'> | / <'border-image-width'>? / <'border-image-outset'> ]? || <'border-image-repeat'>
InitialSee individual properties
Applies toSee individual properties
InheritedNo
AnimationSee individual properties
SupportChrome 16 · Firefox 15 · Safari 6
Speccss-borders-4

With the default border-image-width of 1 the image is drawn at the border's own width, so the element still needs a border style and width. If the image fails to load, the ordinary border is drawn instead.

border: 12px solid transparent;
border-image: url(frame.png) 30 round;
Slice 30 pixels in from each edge of the image and tile the edge pieces evenly round a 12px border.

border-image-source

The image to draw in the border area: a url(), a gradient or any other <image>. With none, the border styles are used.

Syntaxnone | <image>
Initialnone
Applies toAll elements, except internal table elements when border-collapse is collapse
InheritedNo
AnimationDiscrete
SupportChrome 15 · Firefox 15 · Safari 6
Speccss-borders-4

border-image-slice

Where to cut the image into its nine pieces, as insets from the top, right, bottom and left edges (one to four values, in the same order as margin). A plain number is in the image's own pixels. The middle piece is thrown away unless fill is given, in which case it is drawn over the background.

Syntax[<number [0,∞]> | <percentage [0,∞]>]{1,4} && fill?
Initial100%
Applies toAll elements, except internal table elements when border-collapse is collapse
InheritedNo
PercentagesRefer to the size of the border image
AnimationBy computed value
SupportChrome 15 · Firefox 15 · Safari 6
Speccss-borders-4

border-image-width

How thick the border image is drawn on each side, which can differ from border-width. A plain number is a multiple of the border width; auto uses the natural size of the slice.

Syntax[ <length-percentage [0,∞]> | <number [0,∞]> | auto ]{1,4}
Initial1
Applies toAll elements, except internal table elements when border-collapse is collapse
InheritedNo
PercentagesRelative to the width or height of the border image area
AnimationBy computed value
SupportChrome 16 · Firefox 13 · Safari 6
Speccss-borders-4

border-image-outset

How far the border image area reaches beyond the border box. A plain number is a multiple of the border width. The overhang does not affect layout.

Syntax[ <length [0,∞]> | <number [0,∞]> ]{1,4}
Initial0
Applies toAll elements, except internal table elements when border-collapse is collapse
InheritedNo
AnimationBy computed value
SupportChrome 15 · Firefox 15 · Safari 6
Speccss-borders-4

border-image-repeat

How the edge pieces fill the length of each side. The first value applies to the top and bottom edges, the second to the left and right.

Syntax[ stretch | repeat | round | space ]{1,2}
Initialstretch
Applies toAll elements, except internal table elements when border-collapse is collapse
InheritedNo
AnimationDiscrete
SupportChrome 15 · Firefox 15 · Safari 6
Speccss-borders-4
ValueEffect
stretchOne copy of the piece, stretched to fill the side.
repeatThe piece is tiled from the centre of the side; tiles at the ends may be cut off.
roundThe piece is tiled, and scaled so a whole number of tiles fits.
spaceAs many whole tiles as fit, with the leftover space shared out between them.

Border shape

border-shape

Draws the border along a <basic-shape>, such as polygon() or shape(), instead of the box's rectangle. With one shape the border is stroked along it at the border width; with two, the border fills the area between the outer and the inner shape. The optional box keyword after each shape sets the box it is measured against.

Syntaxnone | [ <basic-shape> <geometry-box>?]{1,2}
Initialnone
Applies toAll elements
InheritedNo
AnimationBy computed value
SupportChrome 147 · Firefox no · Safari no
Speccss-borders-4

Outline

outline

Shorthand for the width, style and colour of an outline: a line drawn just outside the border edge. An outline takes up no space and never moves anything, which makes it the usual way to show keyboard focus.

Syntax<'outline-width'> || <'outline-style'> || <'outline-color'>
InitialSee individual properties
Applies toAll elements
InheritedNo
AnimationSee individual properties
SupportChrome 94 · Firefox 88 · Safari 16.4
Speccss-ui-4

The shorthand itself has worked since Chrome 1, Firefox 1.5 and Safari 1.2. The versions above are the first in which the outline follows the box's border-radius instead of staying rectangular.

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
A visible focus ring with a small gap from the element's edge.

outline-color

The colour of the outline.

Syntaxauto | <'border-top-color'>
Initialauto
Applies toAll elements
InheritedNo
AnimationBy computed value
SupportChrome 1 · Firefox 1.5 · Safari 1.2
Speccss-ui-4

outline-style

The line style of the outline. It takes the same keywords as border-style except hidden, plus auto, which lets the browser draw its own focus-ring style.

Syntaxauto | <outline-line-style>
Initialnone
Applies toAll elements
InheritedNo
AnimationBy computed value
SupportChrome 1 · Firefox 1.5 · Safari 1.2
Speccss-ui-4

outline-width

The thickness of the outline, taking the same lengths and keywords as the border widths. It computes to 0 while outline-style is none.

Syntax<line-width>
Initialmedium
Applies toAll elements
InheritedNo
AnimationBy computed value
SupportChrome 1 · Firefox 1.5 · Safari 1.2
Speccss-ui-4

outline-offset

The gap between the border edge and the outline. A negative value draws the outline inside the border box.

Syntax<length>
Initial0
Applies toAll elements
InheritedNo
AnimationBy computed value
SupportChrome 1 · Firefox 1.5 · Safari 1.2
Speccss-ui-4