CSS Borders and Box Decorations Module Level 4

W3C Working Draft,

More details about this document
This version:
https://www.w3.org/TR/2026/WD-css-borders-4-20260326/
Latest published version:
https://www.w3.org/TR/css-borders-4/
Editor's Draft:
https://drafts.csswg.org/css-borders-4/
History:
https://www.w3.org/standards/history/css-borders-4/
Feedback:
CSSWG Issues Repository
Inline In Spec
Editors:
Elika J. Etemad / fantasai (Apple)
Lea Verou (Invited Expert)
(Invited Expert)
Noam Rosenthal (Google)
Former Editor:
(W3C)
Suggest an Edit for this Spec:
GitHub Editor
Test Suite:
https://wpt.fyi/results/css/css-borders/

Abstract

This module contains the features of CSS relating to the borders and decorations of boxes on the page.

CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, etc.

Status of this document

This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C standards and drafts index.

This document was published by the CSS Working Group as a Working Draft using the Recommendation track. Publication as a Working Draft does not imply endorsement by W3C and its Members.

This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than a work in progress.

Please send feedback by filing issues in GitHub (preferred), including the spec code “css-borders” in the title, like this: “[css-borders] …summary of comment…”. All issues and comments are archived. Alternately, feedback can be sent to the (archived) public mailing list www-style@w3.org.

This document is governed by the 18 August 2025 W3C Process Document.

This document was produced by a group operating under the W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent that the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

1. Introduction

The properties of this module deal with the decoration of the border area. It also defines decorations that can be applied to the box.

1.1. Module Interactions

This specification extends the parts related to borders and box decorations of CSS Backgrounds and Borders Module Level 3 [CSS3BG].

It provides specifications for the added corner-*-shape and border-shape properties, as well as logical shorthands for border-*-radius, box-shadow-* longhands, and partial borders via the border-limit and border-*-clip properties.

All properties in this module apply to the ::first-letter pseudo-element. The border-radius properties also apply to the ::first-line pseudo-element. The UA may (but is not required to) apply the border-image or box-shadow properties to ::first-line. The UA must not apply the border-color/style/width properties to ::first-line. [CSS2]

1.2. Value Definitions

This specification follows the CSS property definition conventions from [CSS2] using the value definition syntax from [CSS-VALUES-3]. Value types not defined in this specification are defined in CSS Values & Units [CSS-VALUES-3]. Combination with other CSS modules may expand the definitions of these value types. For example, combining with CSS Images allows for using CSS gradients as background-image or border-image values. [CSS-IMAGES-3]

In addition to the property-specific values listed in their definitions, all properties defined in this specification also accept the CSS-wide keywords as their property value. For readability they have not been repeated explicitly.

2. Borders

The border can either be a predefined style (solid line, double line, dotted line, pseudo-3D border, etc.) or it can be an image. In the former case, various properties define the style (border-style), color (border-color), and thickness (border-width) of the border.

Tests

Tests for features Not yet incorporated from Backgrounds 3


2.1. Line Colors: the border-color properties

Name: border-top-color, border-right-color, border-bottom-color, border-left-color, border-block-start-color, border-block-end-color, border-inline-start-color, border-inline-end-color
Value: <color> | <image-1D>
Initial: currentcolor
Applies to: all elements except ruby base containers and ruby annotation containers
Inherited: no
Percentages: N/A
Computed value: the computed color and/or a one-dimensional image function
Canonical order: per grammar
Animation type: see prose
Logical property group: border-color

These properties set the foreground color of the border specified by the border-style properties.

The stripes defined by <image-1D> follow the shape of the border on the side to which they apply, and are drawn in bands starting from the padding edge and progressing outwards. The border width at each point defines the total width of the stripes at that point.

Using multiple colors for each side:
.foo {
  border: 30px solid;
  border-color: stripes(dodgerblue, skyblue) stripes(yellow, gold) stripes(lightgreen, limegreen) stripes(indianred, orange);
}

Sample rendering:

A box with a border that has four sides,
		          each side having two colors in stripes.
		          The top border is dodger blue and sky blue,
		          the right border is yellow and gold,
		          the bottom border is light green and lime green,
		          and the left border is indian red and orange.

The same border colors with border-style: dotted:

A box with a border that has four sides,
		          each side having two colors in stripes.
		          The top border is dodger blue and sky blue,
		          the right border is yellow and gold,
		          the bottom border is light green and lime green,
		          and the left border is indian red and orange.
		          The border style is dotted, so the colors appear in dots along the border.

Name: border-color
Value: [ <color> | <image-1D> ]{1,4}
Initial: see individual properties
Applies to: see individual properties
Inherited: see individual properties
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar

border-color is a shorthand property for the four physical border-*-color properties. The four values set the top, right, bottom and left border, respectively. A missing left is the same as right, a missing bottom is the same as top, and a missing right is also the same as top. This is resolved individually for each list item.

The flow-relative properties border-block-start-color, border-block-end-color, border-inline-start-color, and border-inline-end-color correspond to the physical properties border-top-color, border-bottom-color, border-left-color, and border-right-color. The mapping depends on the element’s writing-mode, direction, and text-orientation.

Name: border-block-color, border-inline-color
Value: <'border-top-color'>{1,2}
Initial: see individual properties
Applies to: see individual properties
Inherited: see individual properties
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar

These two shorthand properties set the border-block-start-color & border-block-end-color and border-inline-start-color & border-inline-end-color, respectively. The first value represents the start side color, and the second value represents the end side color. If only one value is given, it applies to both the start and end sides.

Tests

2.2. Line Patterns: the border-style properties

Name: border-top-style, border-right-style, border-bottom-style, border-left-style, border-block-start-style, border-block-end-style, border-inline-start-style, border-inline-end-style
Value: <line-style>
Initial: none
Applies to: all elements except ruby base containers and ruby annotation containers
Inherited: no
Percentages: N/A
Computed value: specified keyword
Canonical order: per grammar
Animation type: discrete
Logical property group: border-style

These properties control whether a border appears, and if it does what style it’s drawn in (if it is not overridden by a border image).

The flow-relative properties border-block-start-style, border-block-end-style, border-inline-start-style, and border-inline-end-style correspond to the physical properties border-top-style, border-bottom-style, border-left-style, and border-right-style. The mapping depends on the element’s writing-mode, direction, and text-orientation.

Name: border-block-style, border-inline-style
Value: <'border-top-style'>{1,2}
Initial: see individual properties
Applies to: see individual properties
Inherited: see individual properties
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar

These two shorthand properties set the border-block-start-style & border-block-end-style and border-inline-start-style & border-inline-end-style, respectively. The first value represents the start side style, and the second value represents the end side style. If only one value is given, it applies to both the start and end sides.

Name: border-style
Value: <'border-top-style'>{1,4}
Initial: see individual properties
Applies to: see individual properties
Inherited: see individual properties
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar

border-style is a shorthand property for the four physical border-*-style properties. The four values set the top, right, bottom and left border, respectively. A missing left is the same as right, a missing bottom is the same as top, and a missing right is also the same as top. This is resolved individually for each list item.

The style is specified as a <line-style> keyword, where

<line-style> = none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset

Values have the following meanings:

none
No border. Color and width are ignored (i.e., the border has width 0). Note this means that the initial value of border-image-width will also resolve to zero.
hidden
Same as none, but has different behavior in the border conflict resolution rules for border-collapsed tables [CSS2].
dotted
A series of round dots.
dashed
A series of square-ended dashes.
solid
A single line segment.
double
Two parallel solid lines with some space between them. (The thickness of the lines is not specified, but the sum of the lines and the space must equal border-width.)
groove
Looks as if it were carved in the canvas. (This is typically achieved by creating a “shadow” from two colors that are slightly lighter and darker than the specified border-color.)
ridge
Looks as if it were coming out of the canvas.
inset
Looks as if the content on the inside of the border is sunken into the canvas. Treated as ridge in the collapsing border model. [CSS2]
outset
Looks as if the content on the inside of the border is raised out of the canvas. Treated as groove in the collapsing border model. [CSS2]

Borders are drawn in front of the element’s background, but behind the element’s content (in case it overlaps).

Example renderings of the predefined border styles.

Note: Border colors close to black or white may need different color calculations than colors in between in order to create the required “3D” effect of groove, ridge, inset, or outset.

Note: There is no control over the spacing of the dots and dashes, nor over the length of the dashes. Implementations are encouraged to choose a spacing that makes the corners symmetrical.

Tests

2.3. Line Thickness: the border-width properties

Name: border-top-width, border-right-width, border-bottom-width, border-left-width, border-block-start-width, border-block-end-width, border-inline-start-width, border-inline-end-width
Value: <line-width>
Initial: medium
Applies to: all elements except ruby base containers and ruby annotation containers
Inherited: no
Percentages: N/A
Computed value: absolute length, snapped as a border width
Canonical order: per grammar
Animation type: by computed value
Logical property group: border-width

These properties specify the thickness of the border, i.e. the border width. Where

<line-width> = <length [0,∞]> | hairline | thin | medium | thick

Negative values are invalid. The thin, medium, and thick keywords are equivalent to 1px, 3px, and 5px, respectively. The hairline keyword is a UA-defined length, less than or equal to 1px and equal to an integer number of device pixels at the default page zoom, which represents a "just visible" line. (While it can be as large as 1px, on many devices it will be approximately 0.3px to 0.5px.)

The resolved value for the border-width properties is the used value.

If the border-style corresponding to a given border-width is none or hidden, then the used width is 0.

The flow-relative properties border-block-start-width, border-block-end-width, border-inline-start-width, and border-inline-end-width correspond to the physical properties border-top-width, border-bottom-width, border-left-width, and border-right-width. The mapping depends on the element’s writing-mode, direction, and text-orientation.

Name: border-block-width, border-inline-width
Value: <'border-top-width'>{1,2}
Initial: see individual properties
Applies to: see individual properties
Inherited: see individual properties
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar

These two shorthand properties set the border-block-start-width & border-block-end-width and border-inline-start-width & border-inline-end-width, respectively. The first value represents the start side width, and the second value represents the end side width. If only one value is given, it applies to both the start and end sides.

Name: border-width
Value: <'border-top-width'>{1,4}
Initial: see individual properties
Applies to: see individual properties
Inherited: see individual properties
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar

border-width is a shorthand property for the four physical border-*-width properties. The four values set the top, right, bottom and left border, respectively. A missing left is the same as right, a missing bottom is the same as top, and a missing right is also the same as top. This is resolved individually for each list item.

Note: Although the initial width is medium, the initial style is none; therefore the used initial width is 0.

Tests

2.4. Border Shorthand Properties

Name: border-top, border-right, border-bottom, border-left, border-block-start, border-block-end, border-inline-start, border-inline-end
Value: <line-width> || <line-style> || <color>
Initial: See individual properties
Applies to: all elements except ruby base containers and ruby annotation containers
Inherited: no
Percentages: N/A
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar

These shorthand properties set the border-width, border-color, and border-style of one side of the borders of a box. Omitted values are set to their initial values.

The flow-relative properties border-block-start, border-block-end, border-inline-start, and border-inline-end correspond to the physical properties border-top, border-bottom, border-left, and border-right. The mapping depends on the element’s writing-mode, direction, and text-orientation.

Name: border-block, border-inline
Value: <'border-block-start'>
Initial: see individual properties
Applies to: see individual properties
Inherited: see individual properties
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar

These two shorthand properties set the border-block-start & border-block-end or border-inline-start & border-inline-end, respectively, both to the same style.

Name: border
Value: <line-width> || <line-style> || <color>
Initial: see individual properties
Applies to: see individual properties
Inherited: see individual properties
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar
Tests

The border property is a shorthand property for setting the same border-width, border-color, and border-style for all four borders of a box. Unlike the shorthand margin and padding properties, the border property cannot set different values on the four borders. To do so, one or more of the other border properties must be used.

The border shorthand also resets border-image to its initial value. It is therefore recommended that authors use the border shorthand, rather than other shorthands or the individual properties, to override any border settings earlier in the cascade. This will ensure that border-image has also been reset to allow the new styles to take effect.

Note: The CSS Working Group intends for the border shorthand to reset all border properties in future levels of CSS as well. For example, if a border-characters property is introduced in the future to allow glyphs as borders, it will also be reset by the border shorthand. By using the border shorthand to reset borders, authors can be guaranteed a “blank canvas” no matter what properties are introduced in the future.

For example, the first rule below is equivalent to the set of five rules shown after it:
p { border: solid red }
p {
  border-top: solid red;
  border-right: solid red;
  border-bottom: solid red;
  border-left: solid red;
  border-image: none;
}

Since, to some extent, the properties have overlapping functionality, the order in which the rules are specified is important.

Consider this example:
blockquote {
  border-color: red;
  border-left: double;
  color: black
}

In the above example, the color of the left border is black, while the other borders are red. This is due to border-left setting the width, style, and color. Since the color value is not given by the border-left property, it will be taken from the color property. The fact that the color property is set after the border-left property is not relevant.

3. Corners

The padding edge (inner border) radius is the outer border radius minus the corresponding border thickness. In the case where this results in a negative value, the inner radius is zero. (In such cases the center of the border’s inner curve might not coincide with that of its outer curve.) Likewise the content edge radius is the padding edge radius minus the corresponding padding, or if that is negative, zero. The border and padding thicknesses in the curved region are thus interpolated from the adjoining sides, and when two adjoining borders are of different thicknesses the corner will show a smooth transition between the thicker and thinner borders.

All border styles (solid, dotted, inset, etc.) follow the curve of the border.

The effect of a rounded corner when the two borders it connects are of unequal thickness (left) and the effect of a rounded corner on borders that are thicker than the radius of the corner (right).

Note: If the center of a corner’s outer curve is past an opposite padding edge (in the border area of a side opposite the corner), the inner curve will not be a full quarter ellipse.

p { width: 70px; height: 70px; border: solid 30px;
border-color: orange orange silver silver;
border-top-right-radius: 100%; }
The curved corner is an arc from the top left corner
					          sweeping across the top right corner to the bottom right corner,
					          describing a quarter-ellipse;
					          but since the opposite sides have a border thickness
					          the padding edge curve starts inward from the outer arc's endpoints.
Where the border-radius curve extends into the opposite sides' borders, the arc of the padding edge is less than 90°.

The margin edge, being outside the border edge, calculates its radius by adding the corresponding margin thickness to each border radius, with the corresponding outset-adjusted border radius applied.

When expanding an edge that has a border radius, e.g. for computing the margin edge, box-shadow spread, or overflow-clip-margin, the different border radius values are adjusted so that a small rounded corner with a big outset does not appear to be disproportionally round.

This is done by computing the corresponding outset-adjusted border radius.

To compute the outset-adjusted border radius given the 2-dimensional size’s edge, radius, and outset:

  1. Let coverage be 2 * min(radius’s width / edge’s width, radius’s height / edge’s height).

  2. Let adustedRadiusWidth be the adjusted radius dimension given coverage, radius’s width, and outset’s width.

  3. Let adustedRadiusHeight be the adjusted radius dimension given coverage, radius’s height, and outset’s height.

  4. Return (adustedRadiusWidth, adustedRadiusHeight).

To compute the adjusted radius dimension given numbers coverage, radius, and outset:

  1. If radius is greater than spread, or if coverage is greater than 1, then return radius + outset.

  2. Let ratio be radius / outset.

  3. Return radius + outset * (1 - (1 - ratio)3 * (1 - coverage3)).

Note: this algorithm is designed to reduce the effect of the outset (or spread) on the shape of the corner. The coverage factor makes this reduction more pronounced for rectangular shapes (where the border radius is close to 0), and less pronounced for elliptical shapes (where the border radius is close to 50%).

3.1. Corner Clipping

Although border images are not affected by border-radius, other effects that clip painting or event handling to the border, padding, or content edge must clip to their respective curves. For example, backgrounds clip to the curve specified by background-clip, overflow values other than visible to the curved padding edge (when overflow on both axes is not visible), replaced element content to the curved content edge, pointer events to the curved border edge, etc.

Note: As border-radius reduces the interactive area of an element authors should make sure the remaining interactive area conforms to recommended minima for the platforms they target; in particular, conforming to recommended minimum touch target sizes may require larger widths and heights when border-radius is used.

This example adds appropriate padding, so that the contents do not overflow the corners. Note that there is no border, but the background will still have rounded corners.
DIV {
    background: black;
    color: white;
    border-radius: 1em;
    padding: 1em }

3.2. Color and Style Transitions

Color and style transitions must be contained within the segment of the border that intersects the smallest rectangle that contains both border radii as well as the center of the inner curve (which may be a point representing the corner of the padding edge, if the border radii are smaller than the border width).

If one of these borders is zero-width, then the other border takes up the entire transitional area. Otherwise, the center of color and style transitions between adjoining borders is a point along the curve that is a continuous monotonic function of the ratio of the border widths. However it is not defined what these transitions look like or what function maps from this ratio to a point on the curve.

Given these corner shapes, color and style transitions must be contained within the green region. In case D the rectangle defined by the border radii does not include the center of the inner curve (which is a sharp corner), so the transition region is expanded to include that corner. Transitions may take up the entire transition region, but are not required to: For example, a gradient color transition between two solid border styles might take up only the region bounded by the tips of the outer radii and the tips of the inner radii (represented in case D by the dark green region).
Tests

3.3. Overlapping Curves

Corner curves must not overlap: When the sum of any two adjacent border radii exceeds the size of the border box, UAs must proportionally reduce the used values of all border radii until none of them overlap. The algorithm for reducing radii is as follows:

Let f = min(Li/Si), where i ∈ {top, right, bottom, left}, Si is the sum of the two corresponding radii of the corners on side i, and Ltop = Lbottom = the width of the box, and Lleft = Lright = the height of the box. If f < 1, then all corner radii are reduced by multiplying them by f.

Note: This formula ensures that quarter circles remain quarter circles and large radii remain larger than smaller ones, but it may reduce corners that were already small enough, which may make borders of nearby elements that should look the same look different.

If the curve interferes with UI elements such as scrollbars, the UA may further reduce the used value of the affected border radii (and only the affected border radii) as much as necessary, but no more.

For example, the borders A of the figure below might be the result of
box-sizing: border-box;
width: 6em;
height: 2.5em;
border-radius: 0.5em 2em 0.5em 2em

The height (2.5em) is enough for the specified radii (0.5em plus 2.0em). However, if the height is only 2em,

box-sizing: border-box;
width: 6em;
height: 2em;
border-radius: 0.5em 2em 0.5em 2em

all corners need to be reduced by a factor 0.8 to make them fit. The used border radii thus are 0.4em (instead of 0.5em) and 1.6em (instead of 2em). See borders B in the figure.