GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing developer.mozilla.org — text-box CSS property - CSS | MDN
|
| Initial value | normal |
|---|---|
| Applies to | Block containers and inline boxes |
| Inherited | no |
| Computed value | the specified keyword |
| Animation type | discrete |
text-box =
normal |
<'text-box-trim'> || <'text-box-edge'>
<text-box-trim> =
none |
trim-start |
trim-end |
trim-both
<text-box-edge> =
auto |
<text-edge>
<text-edge> =
[ text | ideographic | ideographic-ink ] |
[ text | ideographic | ideographic-ink | cap | ex ] [ text | ideographic | ideographic-ink | alphabetic ]
text-box usageIn the following example, we have two <p> elements with classes of one and two.
We apply a text-box value of trim-end cap alphabetic to the first paragraph. The text-box-edge value of cap alphabetic specifies trimming the over edge to the top of the capital letters and the under edge flush with the text baseline. Because the text-box-trim value is set to trim-end, only the under edge of the paragraph is trimmed.
We apply a text-box value of trim-both ex alphabetic to the second paragraph. The text-box-edge value of ex alphabetic specifies trimming the over edge to the font's x-height (the top edge of the short lower-case letters) and the under edge flush with the text baseline. Because the text-box-trim value is set to trim-both, both the over and under edge of the paragraph are trimmed.
<p class="one">This is .one</p>
<p class="two">This is .two</p>
html {
font-family: sans-serif;
height: 100%;
}
body {
height: inherit;
display: flex;
flex-direction: column;
justify-content: center;
gap: 100px;
}
p {
margin: 0;
font-size: 6rem;
font-weight: bold;
}
.one {
text-box: trim-end cap alphabetic;
}
.two {
text-box: trim-both ex alphabetic;
}
p {
border-top: 5px solid magenta;
border-bottom: 5px solid magenta;
}
The output is as follows. Note how we've included a top and bottom border on each paragraph, so that you can see how the space has been trimmed in each case.
| Specification |
|---|
| CSS Inline Layout Module Level 3 # text-box-shorthand |
text-box-edge, text-box-trim<text-edge> data type