You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: css-inline-3/Overview.bs
+175-185
Original file line number
Diff line number
Diff line change
@@ -340,6 +340,116 @@ Alignment Shift: the 'baseline-shift' longhand</h4>
340
340
<h3 id="line-height-property">
341
341
Line Spacing: the 'line-height' property</h3>
342
342
343
+
344
+
As described in the section on <a href="https://www.w3.org/TR/CSS2/visuren.html#inline-formatting">inline formatting contexts</a>[[CSS2/visuren.html#inline-formatting]],
345
+
user agents flow inline-level boxes into a vertical stack of [=line boxes=].
346
+
The height of a line box is determined as follows:
347
+
348
+
<ol>
349
+
<li>
350
+
The height of each [=inline-level box=] in the line box is calculated.
351
+
For replaced elements, inline-block elements, and inline-table elements,
352
+
this is the height of their [=margin box=];
353
+
for [=inline boxes=], this is their 'line-height'.
354
+
355
+
<li>
356
+
The inline-level boxes are aligned vertically
357
+
according to their 'vertical-align' property.
358
+
359
+
In case they are aligned ''top'' or ''bottom'',
360
+
they must be aligned so as to minimize the line box height.
361
+
If such boxes are tall enough,
362
+
there are multiple solutions
363
+
and CSS 2 does not define the position of the line box's baseline
364
+
(i.e., the position of the [=strut=]).
365
+
366
+
<li>
367
+
The line box height is the distance between
368
+
the uppermost box top and the lowermost box bottom.
369
+
(This includes the [=strut=],
370
+
as explained under 'line-height' below.)
371
+
</ol>
372
+
373
+
Empty inline elements generate empty inline boxes,
374
+
but these boxes still have margins, padding, borders, and a line height,
375
+
and thus influence these calculations just like elements with content.
376
+
377
+
<h4 id="leading">Leading and half-leading</h4>
378
+
379
+
CSS assumes that every font has font metrics
380
+
that specify a characteristic height above the baseline and a depth below it.
381
+
In this section we use <var>A</var> to mean that height
382
+
(for a given font at a given size)
383
+
and <var>D</var> the depth.
384
+
We also define <var>AD</var> = <var>A</var> + <var>D</var>,
385
+
the distance from the top to the bottom.
386
+
(See the note below for <a href="#sTypoAscender">how to find <var>A</var> and <var>D</var> for TrueType and OpenType fonts.</a>)
387
+
Note that these are metrics of the font as a whole
388
+
and need not correspond to the ascender and descender of any individual glyph.
389
+
390
+
The User Agent must align the glyphs in a non-replaced inline box
391
+
to each other by their relevant baselines.
392
+
Then, for each glyph,
393
+
determine the <var>A</var> and <var>D</var>.
394
+
Note that glyphs in a single element
395
+
may come from different fonts
396
+
and thus need not all have the same <var>A</var> and <var>D</var>.
397
+
If the inline box contains no glyphs at all,
398
+
or if it contains only glyphs from fallback fonts,
399
+
it is considered to contain a [=strut=] (an invisible glyph of zero width)
400
+
with the <var>A</var> and <var>D</var> of the element's first available font.
401
+
402
+
<p id="inline-box-height">When the value of the 'line-height' property
403
+
is something other than ''line-height/normal'',
404
+
determine the leading <var>L</var> to add,
405
+
where <var>L</var> = 'line-height' - <var>AD</var> of the first available font.
406
+
Half the leading is added above <var>A</var> of the first available font,
407
+
and the other half below <var>D</var> of the first available font,
408
+
giving a total height above the baseline of
409
+
<var>A'</var> = <var>A</var> + <var>L</var>/2,
410
+
and a total depth of <var>D'</var> = <var>D</var> + <var>L</var>/2.
411
+
Glyphs from fonts other than the first available font
412
+
do not impact the height or baseline of the inline box
413
+
for 'line-height' values other than ''line-height/normal''.
414
+
415
+
Note: <var>L</var> may be negative.
416
+
417
+
Boxes of child elements do not influence this height.
418
+
419
+
When the value of the 'line-height' property is ''line-height/normal'',
420
+
the height of the inline box encloses all glyphs,
421
+
going from the highest <var>A</var> to the deepest <var>D</var>.
422
+
423
+
User Agents may use different sets of font metrics
424
+
when determining <var>A</var> and <var>D</var>
425
+
depending on whether the 'line-height' property is
426
+
''line-height/normal'' or some other value,
427
+
for instance taking external leading metrics into account
428
+
only in the ''line-height/normal'' case.
429
+
430
+
Although margins, borders, and padding of non-replaced elements
431
+
do not enter into the line box calculation,
432
+
they are still rendered around inline boxes.
433
+
This means that if the height specified by 'line-height'
434
+
is less than the content height of contained boxes,
435
+
backgrounds and colors of padding and borders may "bleed" into adjoining line boxes.
436
+
User agents should render the boxes in document order.
437
+
This will cause the borders on subsequent lines
438
+
to paint over the borders and text of previous lines.
439
+
440
+
Note: CSS 2 does not define what the content area of an inline box is
441
+
(see [[#line-fill]])
442
+
and thus different UAs may draw the backgrounds and borders in different places.
443
+
444
+
<p class=note id=sTypoAscender>Note: It is recommended that
445
+
implementations that use OpenType or TrueType fonts
446
+
use the metrics <code>sTypoAscender</code> and <code>sTypoDescender</code>
447
+
from the font's OS/2 table
448
+
for <var>A</var> and <var>D</var>
449
+
(after scaling to the current element's font size).
450
+
In the absence of these metrics,
451
+
the "Ascent" and "Descent" metrics from the HHEA table should be used.
452
+
343
453
<pre class="propdef">
344
454
Name: line-height
345
455
Value: normal | <<number>> || <<length-percentage>>
@@ -350,191 +460,71 @@ Line Spacing: the 'line-height' property</h3>
350
460
Computed value: the specified keyword, a number, or a computed <<length>> value
0 commit comments