Skip to content

Commit 85c14e5

Browse files
committed
[css-inline-3] Define the CSS inline layout model; stealing heavily from CSS2 section 9.4.2.
1 parent 54b2c2a commit 85c14e5

1 file changed

Lines changed: 97 additions & 12 deletions

File tree

css-inline-3/Overview.bs

Lines changed: 97 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,6 @@ Introduction</h2>
4040
replacing and extending the model as defined in CSS2.1.
4141
It is very much a work-in-progress, and implementers should reference CSS2.1 for now.
4242

43-
The <dfn export>root inline box</dfn> is an anonymous inline box
44-
which is automatically generated to hold
45-
all of the <a>inline-level</a> contents of a <a>block container</a>
46-
(if it has any).
47-
It inherits from its parent <a>block container</a>,
48-
but is otherwise unstyleable.
49-
50-
Note: Line boxes, like <a>column boxes</a> [[css-multicol-1]],
51-
are <a>fragmentation containers</a> generated by their <a>formatting context</a>
52-
and are not part of the CSS <a>box tree</a>.
53-
5443
ISSUE: Many aspects of layout here depend on font metrics.
5544
While the relevant metrics exist in OpenType for Latin/Cyrillic/Greek and for CJK,
5645
they are missing for many other writing systems.
@@ -60,6 +49,102 @@ Introduction</h2>
6049
and that means both that OpenType needs to allow such metrics
6150
and font designers need to provide accurate numbers.
6251

52+
<h2 id="model">
53+
Inline Layout Box Model</h2>
54+
55+
A [=block container=] element that directly contains
56+
[=inline-level=] content--
57+
such as [=inline boxes=], [=atomic inlines=], and [=text runs=]--
58+
establishes an [=inline formatting context=].
59+
The [=block container=] also generates
60+
a <dfn export>root inline box</dfn>,
61+
which is an <a lt="anonymous box">anonymous</a> [=inline box=] that holds
62+
all of its [=inline-level=] contents.
63+
The [=root inline box=] inherits from its parent [=block container=],
64+
but is otherwise unstyleable.
65+
66+
In an [=inline formatting context=],
67+
content is laid out along the [=inline axis=],
68+
ordered according to the
69+
<a href="https://www.w3.org/TR/css-writing-modes-3/#text-direction">Unicode bidirectional algorithm and its controls</a> [[CSS-WRITING-MODES-3]]
70+
and distributed according to the typesetting controls in [[CSS-TEXT-3]].
71+
[=Inline-axis=] [=margins=], [=borders=], and [=padding=]
72+
are respected between [=inline-level boxes=]
73+
(and their margins do not <a href="https://www.w3.org/TR/CSS2/box.html#collapsing-margins">collapse</a>).
74+
The rectangular area that contains the boxes
75+
that form a line of [=inline-level content=]
76+
is called a <dfn>line box</dfn>.
77+
78+
Note: <a>Line boxes</a> and <a>inline boxes</a> and <a>inline-level boxes</a>
79+
are each different things!
80+
See [[CSS-DISPLAY-3]] for an in-depth discussion of box types and related terminology.
81+
82+
[=Line boxes=] are created as needed
83+
to hold inline-level content
84+
within an inline formatting context.
85+
When an [=inline box=] exceeds the [=logical width=] of a [=line box=],
86+
or contains a <a spec="css-text-3">forced line break</a>,
87+
it is split (see [[css-text-3#line-breaking]])
88+
into several [=fragments=] [[css-break-3]],
89+
which are distributed across multiple line boxes.
90+
Like [=column boxes=] in [=multi-column layout=] [[CSS-MULTICOL-1]],
91+
[=line boxes=] are [=fragmentation containers=]
92+
generated by their [=formatting context=],
93+
and are not part of the CSS [=box tree=].
94+
95+
Note: Inline boxes can also be <a href="https://www.w3.org/TR/css-writing-modes-3/#bidi-box-model">split into several fragments
96+
within the same line box due to bidirectional text processing</a>.
97+
See [[CSS-WRITING-MODES-3]].
98+
99+
Line boxes are stacked
100+
as the direct contents of the [=block container box=]
101+
in the [=block flow direction=]
102+
and aligned within this container as specified by 'align-content' [[css-align-3]].
103+
Thus, an [=inline formatting context=] consists of
104+
a stack of line boxes.
105+
Line boxes are stacked with no separation
106+
(except as specified elsewhere,
107+
e.g. for [=float=] <a href="https://www.w3.org/TR/CSS2/visuren.html#clearance">clearance</a>)
108+
and they never overlap.
109+
110+
In general,
111+
the [=line-left=] edge of a line box touches
112+
the [=line-left=] edge of its [=containing block=]
113+
and the [=line-right=] edge touches
114+
the [=line-right=] edge of its [=containing block=],
115+
and thus the [=logical width=] of a line box is equal to
116+
the <a lt="inner size">inner</a> [=logical width=]
117+
of its containing block
118+
(i.e. the [=block container=]’s [=content box=]).
119+
However, floating boxes or [=initial letter boxes=]
120+
can come between the containing block edge and the line box edge,
121+
reducing space available to, and thus the [=logical width=],
122+
of any such impacted line boxes.
123+
(See [[CSS2/visuren.html#inline-formatting|CSS2&sect;9.4.2]]/[[CSS2/visuren.html#floats|CSS2&sect;9.5]]
124+
and [[#initial-letter-styling]].)
125+
126+
Within the line box,
127+
inline-level boxes can be aligned
128+
along the [=block axis=]
129+
in different ways:
130+
their over or under edges can be aligned,
131+
or the baselines of text within them can be aligned.
132+
See 'vertical-align' and its longhands.
133+
The [=logical height=] of a line box is fitted to its contents
134+
by the rules given in [[#line-sizing-property]].
135+
136+
Line boxes that contain no text,
137+
no [=preserved white space=],
138+
no [=inline boxes=] with non-zero [=margins=], [=padding=], or [=borders=],
139+
and no other [=in-flow=] content
140+
(such as [=atomic inlines=] or [=ruby annotations=]),
141+
and do not end with a preserved newline
142+
must be treated as zero-<a lt="logical height">height</a> line boxes
143+
for the purposes of determining the positions of any elements inside of them
144+
(such as [=absolutely positioned boxes=]),
145+
and must be treated as not existing for any other purpose
146+
(such as <a href="https://www.w3.org/TR/CSS2/box.html#collapsing-margins">collapsing margins</a>).
147+
63148
<h2 id="line-height">
64149
Line Heights and Baseline Alignment</h2>
65150

@@ -517,7 +602,7 @@ Line Spacing: the 'line-height' property</h3>
517602
</div>
518603

519604
Note: When there is only one value of 'line-height'
520-
(other than 'normal')
605+
(other than ''line-height/normal'')
521606
for all inline boxes in a block container box
522607
and they all use the same first available font
523608
(and there are no replaced elements, inline-block elements, etc.),

0 commit comments

Comments
 (0)