<line-width> CSS typeThe <line-width> enumerated value type represents the length or keyword value that defines the width of a line, or the lack of a line. The <line-width> keyword values are used in the following longhand and shorthand properties:
border, border-widthborder-block, border-block-widthborder-block-end, border-block-end-widthborder-block-start, border-block-start-widthborder-bottom, border-bottom-widthborder-inline, border-inline-widthborder-inline-end, border-inline-end-widthborder-inline-start, border-inline-start-widthborder-left, border-left-widthborder-right, border-right-widthborder-top, border-top-widthcolumn-rule, column-rule-widthrow-rule, row-rule-widthrule, rule-widthoutline, outline-widthThe <line-width> type is specified using either <length> or a keyword:
<length>A non-negative <length>.
hairlineRepresents a "just visible" line that is less than or equal to 1px.
thinSame as 1px.
mediumSame as 3px.
thickSame as 5px.
<line-width> =
<length [0,∞]> |
hairline |
thin |
medium |
thick
This example demonstrates all the <line-width> keyword values, along with a <length> value.
We include five boxes within a <section> element.
<section>
<div data-width="hairline">hairline</div>
<div data-width="thin">thin</div>
<div data-width="medium">medium</div>
<div data-width="thick">thick</div>
<div data-width="10px">10px</div>
</section>We style all the elements to be identical, then set the border-width based on the element's data-width attribute.
section {
display: flex;
gap: 10px;
}
div {
flex: 0 0 15%;
border-style: solid;
border-color: purple;
text-align: center;
}
[data-width="hairline"] {
border-width: hairline;
}
[data-width="thin"] {
border-width: thin;
}
[data-width="medium"] {
border-width: medium;
}
[data-width="thick"] {
border-width: thick;
}
[data-width="10px"] {
border-width: 10px;
}<line-style> data type