Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

border-block-start: configure the first edge of a block

Write width, line style and color together for the edge selected by the block writing direction.

Version: CSS Modules

Syntax

border-block-start: <line-width> || <line-style> || <color>;

border-block-start is a shorthand for border-block-start-width, border-block-start-style and border-block-start-color. It targets the top in horizontal-tb, the right in vertical-rl and the left in vertical-lr. It configures one edge, unlike border-block, which configures both block edges. The width, style and color may appear in any unambiguous order.

Omitted components reset to their initial values: medium width, none style and currentColor. Therefore border-block-start: solid does not preserve an earlier explicit width or red color. A shorthand containing only a width or color resets the style to none and generally produces no visible border. Unlike the border shorthand, this logical edge shorthand does not reset border-image.

The example uses a 100×40 content box with a 7px dashed red start edge and a 2px solid blue end edge. Its outer height is 49px. Assigning solid alone produces the browser’s medium width, measured here as 3px, and the element’s rgb(10, 20, 30) color, giving height 45px. The 2px end edge and configured gradient border-image source remain set. The test checks retention of that source, not the appearance of a sliced border image.

Restoring the 7px start edge and switching to vertical-rl moves it to the right. Together with the 2px left end edge, the outer width becomes 109px. That demonstrates why block-start is not a permanent synonym for top. Avoid conflicting logical and physical declarations unless their cascade is intentional; writing-mode controls which physical edge receives the winning value.

Examples

const box=document.createElement('div');
box.style.cssText='width:100px;height:40px;padding:0;border:0 solid;box-sizing:content-box;color:rgb(10,20,30);border-block-start:7px dashed red;border-block-end:2px solid blue;border-image-source:linear-gradient(red,blue)';
document.body.append(box);
const read=()=>{const s=getComputedStyle(box),r=box.getBoundingClientRect();return [s.borderBlockStartWidth,s.borderBlockStartStyle,s.borderBlockStartColor,r.width,r.height].join('|')};
const initial=read();box.style.borderBlockStart='solid';const reset=read();
const retained=getComputedStyle(box).borderBlockEndWidth+','+(getComputedStyle(box).borderImageSource!=='none');
box.style.borderBlockStart='7px dashed red';box.style.writingMode='vertical-rl';
const vertical=getComputedStyle(box).borderRightWidth+','+box.getBoundingClientRect().width;
console.log('initial='+initial+'; reset='+reset+'; retainedEndAndImage='+retained+'; verticalRight='+vertical);

Result

initial=7px|dashed|rgb(255, 0, 0)|100|49; reset=3px|solid|rgb(10, 20, 30)|100|45; retainedEndAndImage=2px,true; verticalRight=7px,109

Executed in Chromium 157.0.8103.51. The observed 3px medium width is an implementation result, not a portable definition of medium.

Sources