CKTIS / CSS
border-top-width — top border thickness
The border-top-width property sets the thickness of the physical top border. It accepts a nonnegative length or a keyword; it does not set the border's style or color.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
border-top-width: <length [0,∞]> | thin | medium | thick;
/* Level 4 additionally defines hairline; implementation support requires verification. */
/* CSS-wide keywords may also be used. */border-top-width controls only the top border's thickness. Its initial value is medium, and it is not inherited. It targets the physical top, not necessarily the block start in the current writing mode.
Supply a nonnegative length such as 8px, or thin, medium, or thick. Level 3 leaves the thicknesses up to the browser, but requires thin ≤ medium ≤ thick and a consistent thickness for each keyword throughout a document. The Level 4 draft assigns them 1px, 3px, and 5px, respectively. Zero is valid; negative values and percentages are invalid. Level 4 adds hairline, a thin line whose thickness is determined by the browser; support requires separate verification.
Width alone is insufficient: the initial border-top-style is none. With none or hidden, the used width is zero. Set a style such as solid to display an ordinary border. A later border, border-top, or border-width shorthand can override this width.
The example reads the width with solid, then changes the style to none and reads it again. The border is invisible at the end, while the text shows both results.
Examples
<!doctype html>
<meta charset="utf-8">
<title>border-top-width</title>
<style>
#box {
border-top-style: solid;
border-top-color: black;
border-top-width: 8px;
}
</style>
<div id="box">border-top-width</div>
<pre id="result"></pre>
<script>
const box = document.getElementById('box');
const visibleWidth = getComputedStyle(box).borderTopWidth;
box.style.borderTopStyle = 'none';
const hiddenWidth = getComputedStyle(box).borderTopWidth;
document.getElementById('result').textContent =
`solid: ${visibleWidth}\nnone: ${hiddenWidth}`;
</script>Result
solid: 8px none: 0px
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.