Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

border-left — the left border

border-left is a shorthand that sets the width, style, and color of the physical left border. Omitted components return to their initial values, so leaving out the style can make the border invisible.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

Level 3: border-left: <line-width> || <line-style> || <color>;
Level 4 (draft): border-left: <line-width> || <line-style> || [ <color> | <image-1D> ];

border-left sets border-left-width, border-left-style, and border-left-color together. It targets the physical left edge, not the start of a line determined by writing direction. The property is not inherited.

The Level 3 syntax is border-left: <line-width> || <line-style> || <color>;. The Level 4 draft also allows a one-dimensional image (<image-1D>) in place of a color: border-left: <line-width> || <line-style> || [ <color> | <image-1D> ];. In both forms, || means that at least one component is required and the components can appear in any order. In Level 3, the width can be a nonnegative length or the keyword thin, medium, or thick. In the Level 4 draft, <line-width> also accepts hairline. Neither level allows percentages. Example styles include solid, dashed, and none.

Omitted components receive their initial values: medium, none, and currentcolor. Consequently, border-left: 6px; resets the style to none, even if it was previously solid; the used width is then zero. To change only the width without resetting style and color, use border-left-width.

The example should display Note with a solid blue left border 6 CSS pixels wide and 12 CSS pixels of padding on every side. This is an expected result, not confirmation of a completed test.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>border-left</title>
<style>
  .note {
    border-left: 6px solid #0055aa;
    padding: 12px;
  }
</style>
<div class="note">Note</div>
</html>

Result

A box containing “Note”, with a solid blue left border 6 CSS pixels wide and 12 CSS pixels of padding on every side.

The example uses Level 3 syntax: `6px` sets the left border’s width, `solid` sets its style, and `#0055aa` sets its color.

Sources