Skip to content

Commit 766b768

Browse files
committed
[css-inline-3] Clarifications to baseline alignment intro
1 parent 8215ed8 commit 766b768

File tree

1 file changed

+36
-22
lines changed

1 file changed

+36
-22
lines changed

css-inline-3/Overview.bs

+36-22
Original file line numberDiff line numberDiff line change
@@ -524,49 +524,63 @@ Baselines of Glyphs and Boxes</h3>
524524
<h2 id="alignment">
525525
Baseline Alignment</h2>
526526

527-
While CSS [=formatting contexts=] usually position content
527+
While most CSS [=formatting contexts=] position content
528528
by aligning boxes with respect to their container’s edges,
529529
[=inline layout=] positions boxes in the [=block axis=]
530530
by aligning them with respect to each other
531531
using their [=baselines=].
532532

533533
More specifically,
534+
(unless using a [=line-relative shift value=])
534535
each glyph or [=inline-level box=]
535-
is typically aligned in the [=block axis=]
536+
is aligned in the [=block axis=]
536537
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
539541
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=].
543552

544553
<div class="example">
545554
<p>Given following sample markup:
546-
<pre>&lt;p&gt;&lt;span class="outer"&gt;Ap &lt;span class="inner"&gt;ਜੀ&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</pre>
555+
<pre highlight=html>&lt;p&gt;&lt;span class="outer"&gt;Ap &lt;span class="inner"&gt;ਜੀ&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</pre>
556+
547557
<p>And the following style rule:
548-
<pre>span.inner { font-size: 75%; }</pre>
558+
<pre highlight=css>.inner { font-size: 75%; }</pre>
559+
549560
<p>The [=baseline sets=] of the parent (<code>.outer</code>) and the child (<code>.inner</code>)
550561
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
554563
by matching up their [=alphabetic baselines=].
564+
555565
<figure>
556566
<img alt="In this example, the distance between each baseline in the baseline set
557567
is compacted 75% in the span with a 75% font size.
558568
Their alphabetic baselines, however, line up."
559569
src="images/baseline-align-sizes.gif">
560570
</figure>
561-
</div>
562571

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''
565580
to the <code>.inner</code> element from the example above,
566581
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,
568583
the child is shifted to the superscript position.
569-
<pre>span.inner { vertical-align: super; font-size: .75em; }</pre>
570584
<figure>
571585
<p><img alt="In this example, the resulting alignment is equivalent to
572586
shifting the parent baseline table upwards by its superscript offset,
@@ -826,10 +840,10 @@ Post-Alignment Shift: the 'baseline-shift' longhand</h4>
826840
</pre>
827841

828842
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>
830844
<<length-percentage>>, ''baseline-shift/sub'', ''baseline-shift/super''
831845
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>
833847
''baseline-shift/top'', ''baseline-shift/center'', and ''baseline-shift/bottom''
834848
shift the [=inline box=] and its contents
835849
relative to the bounds of its [=line box=].
@@ -884,12 +898,12 @@ Post-Alignment Shift: the 'baseline-shift' longhand</h4>
884898
the [=layout bounds=] of that box
885899
and the [=aligned subtrees=] of all child [=inline boxes=]
886900
whose computed 'alignment-baseline' value
887-
is not itself a [=line-relative value=].
901+
is not itself a [=line-relative shift value=].
888902
The [=line-over=] edge of the [=aligned subtree=]
889903
is the highest [=over=] edge of the [=layout bounds=] in the subtree,
890904
and the [=line-under=] edge is analogously the lowest.
891905

892-
ISSUE: The [=line-relative values=] don't fit perfectly
906+
ISSUE: The [=line-relative shift values=] don't fit perfectly
893907
in the dichotomy between 'alignment-baseline' and 'baseline-shift'.
894908
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>
895909
for either option.
@@ -2965,7 +2979,7 @@ Changes</h2>
29652979
(<a href="https://github.com/w3c/csswg-drafts/issues/5168">Issue 5168</a>)
29662980

29672981
<li>
2968-
Shifted the [=line-relative values=] of 'vertical-align'
2982+
Shifted the [=line-relative shift values=] of 'vertical-align'
29692983
from the 'alignment-baseline' longhand to the 'baseline-shift' longhand.
29702984
(<a href="https://github.com/w3c/csswg-drafts/issues/5180">Issue 5180</a>)
29712985

0 commit comments

Comments
 (0)