Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

text-box — trimming the text box

The text-box shorthand sets text-box-trim and text-box-edge, selecting which edges to trim and which font metrics define their boundaries.

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

Syntax

text-box: normal | <'text-box-trim'> || <'text-box-edge'>;

text-box combines text-box-trim and text-box-edge. On a block container, it trims space at the first and last lines, not spacing between every line. It does not remove characters.

none, trim-start, trim-end, and trim-both select the trimming sides. In cap alphabetic, the first metric means cap height and the second means the alphabetic baseline—not individual glyph boundaries.

normal resets both properties to none and auto. Omitting the trimming component means trim-both; omitting metrics means auto. The shorthand overwrites both properties. This is an evolving draft: verify behavior in the target browser.

Examples

<!doctype html>
<meta charset="utf-8">
<title>text-box</title>
<style>
  p {
    margin: 24px;
    font: 48px/2 serif;
    background: #dceeff;
  }
  .trimmed { text-box: trim-both cap alphabetic; }
</style>
<p>HELLO</p>
<p class="trimmed">HELLO</p>

Result

Two HELLO paragraphs. With support for the declaration, the second paragraph's background is shorter in the block direction; exact dimensions depend on font metrics.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources