@@ -524,49 +524,63 @@ Baselines of Glyphs and Boxes</h3>
524
524
<h2 id="alignment">
525
525
Baseline Alignment</h2>
526
526
527
- While CSS [=formatting contexts=] usually position content
527
+ While most CSS [=formatting contexts=] position content
528
528
by aligning boxes with respect to their container’s edges,
529
529
[=inline layout=] positions boxes in the [=block axis=]
530
530
by aligning them with respect to each other
531
531
using their [=baselines=] .
532
532
533
533
More specifically,
534
+ (unless using a [=line-relative shift value=] )
534
535
each glyph or [=inline-level box=]
535
- is typically aligned in the [=block axis=]
536
+ is aligned in the [=block axis=]
536
537
by positioning its [=alignment baseline=]
537
- to match the corresponding [=baseline=] of its parent,
538
- and then potentially shifted from that position
538
+ to match the <em> corresponding</em> [=baseline=] of its parent
539
+ (which is its [=alignment context=] ),
540
+ and then is potentially shifted from that position
539
541
according to its [=post-alignment shift=] .
540
- The [=alignment baseline=] of the box is selected
541
- by the 'alignment-baseline' longhand of 'vertical-align' ;
542
- this defaults to the parent’s' [=dominant baseline=] .
542
+
543
+ Note: Baseline alignment always matches corresponding baselines:
544
+ alphabetic to alphabetic, hanging to hanging, mathematical to mathematical, etc.
545
+
546
+ When aligning a [=box=] , the [=alignment baseline=] is chosen
547
+ according to its 'alignment-baseline' and 'baseline-source' values
548
+ (see shorthand 'vertical-align' ),
549
+ and defaults to matching the parent’s 'dominant-baseline' .
550
+ For a glyph, the [=alignment baseline=] is always determined
551
+ by the parent’s [=dominant baseline=] .
543
552
544
553
<div class="example">
545
554
<p> Given following sample markup:
546
- <pre> <p><span class="outer">Ap <span class="inner">ਜੀ</span></span></p></pre>
555
+ <pre highlight=html> <p><span class="outer">Ap <span class="inner">ਜੀ</span></span></p></pre>
556
+
547
557
<p> And the following style rule:
548
- <pre> span.inner { font-size: 75%; }</pre>
558
+ <pre highlight=css> .inner { font-size: 75%; }</pre>
559
+
549
560
<p> The [=baseline sets=] of the parent (<code> .outer</code> ) and the child (<code> .inner</code> )
550
561
will not match up due to the font size difference.
551
- Since the [=dominant baseline=] is the [=alphabetic baseline=]
552
- (the default in horizontal [=typographic modes=] ),
553
- the child box is aligned to its parent
562
+ The child box is aligned to its parent
554
563
by matching up their [=alphabetic baselines=] .
564
+
555
565
<figure>
556
566
<img alt="In this example, the distance between each baseline in the baseline set
557
567
is compacted 75% in the span with a 75% font size.
558
568
Their alphabetic baselines, however, line up."
559
569
src="images/baseline-align-sizes.gif">
560
570
</figure>
561
- </div>
562
571
563
- <div class="example">
564
- <p> If we assign ''vertical-align: super''
572
+
573
+ <p> The [=alphabetic baseline=] is used here
574
+ because by default a box’s [=alignment baseline=] matches
575
+ the [=dominant baseline=] of its parent,
576
+ and in horizontal [=typographic mode=] ,
577
+ the [=dominant baseline=] itself defaults to the [=alphabetic baseline=] .
578
+
579
+ <p> If we add ''vertical-align: super''
565
580
to the <code> .inner</code> element from the example above,
566
581
the same rules are used to align the <code> .inner</code> child to its parent;
567
- the only difference is in addition to the baseline alignment,
582
+ but in addition to the baseline alignment,
568
583
the child is shifted to the superscript position.
569
- <pre> span.inner { vertical-align: super; font-size: .75em; }</pre>
570
584
<figure>
571
585
<p><img alt="In this example, the resulting alignment is equivalent to
572
586
shifting the parent baseline table upwards by its superscript offset,
@@ -826,10 +840,10 @@ Post-Alignment Shift: the 'baseline-shift' longhand</h4>
826
840
</pre>
827
841
828
842
This property specifies the box’s <dfn>post-alignment shift</dfn> .
829
- The <dfn>baseline-relative values</dfn>
843
+ The <dfn local-lt="baseline-relative values" >baseline-relative shift values</dfn>
830
844
<<length-percentage>> , ''baseline-shift/sub'' , ''baseline-shift/super''
831
845
shift the box relative to its baseline-aligned position,
832
- whereas the <dfn>line-relative values</dfn>
846
+ whereas the <dfn local-lt="line-relative values" >line-relative shift values</dfn>
833
847
''baseline-shift/top'' , ''baseline-shift/center'' , and ''baseline-shift/bottom''
834
848
shift the [=inline box=] and its contents
835
849
relative to the bounds of its [=line box=] .
@@ -884,12 +898,12 @@ Post-Alignment Shift: the 'baseline-shift' longhand</h4>
884
898
the [=layout bounds=] of that box
885
899
and the [=aligned subtrees=] of all child [=inline boxes=]
886
900
whose computed 'alignment-baseline' value
887
- is not itself a [=line-relative value=] .
901
+ is not itself a [=line-relative shift value=] .
888
902
The [=line-over=] edge of the [=aligned subtree=]
889
903
is the highest [=over=] edge of the [=layout bounds=] in the subtree,
890
904
and the [=line-under=] edge is analogously the lowest.
891
905
892
- ISSUE: The [=line-relative values=] don't fit perfectly
906
+ ISSUE: The [=line-relative shift values=] don't fit perfectly
893
907
in the dichotomy between 'alignment-baseline' and 'baseline-shift' .
894
908
There's <a href="https://github.com/w3c/csswg-drafts/issues/5180">decent</a> <a href="https://github.com/w3c/csswg-drafts/issues/5234">arguments</a>
895
909
for either option.
@@ -2965,7 +2979,7 @@ Changes</h2>
2965
2979
(<a href="https://github.com/w3c/csswg-drafts/issues/5168">Issue 5168</a> )
2966
2980
2967
2981
<li>
2968
- Shifted the [=line-relative values=] of 'vertical-align'
2982
+ Shifted the [=line-relative shift values=] of 'vertical-align'
2969
2983
from the 'alignment-baseline' longhand to the 'baseline-shift' longhand.
2970
2984
(<a href="https://github.com/w3c/csswg-drafts/issues/5180">Issue 5180</a> )
2971
2985
0 commit comments