css-page-floats/Overview.bs

Sun, 31 Jan 2016 15:42:31 -0800

author
Peter Linss <[email protected]>
date
Sun, 31 Jan 2016 15:42:31 -0800
changeset 16986
5be73fbc8592
parent 16753
5c66c4afa802
child 16989
255258410d1b
permissions
-rw-r--r--

change //dev.w3.org/csswg/ urls to //drafts.csswg.org/

johanneswilm@15215 1 <h1>CSS Page Floats</h1>
johanneswilm@15215 2
johanneswilm@15215 3 <pre class='metadata'>
bert@16261 4 TR: http://www.w3.org/TR/css-page-floats-3/
bert@16261 5 Status Text: Some of the features in this draft were previously published in <cite>CSS Generated Content for Paged Media Module</cite> [[CSS3GCPM]].
johanneswilm@15215 6 Shortname: css-page-floats
johanneswilm@15215 7 Level: 3
johanneswilm@15215 8 Group: csswg
johanneswilm@15215 9 Status: ED
mail@15765 10 Work Status: Exploring
peter@16986 11 ED: https://drafts.csswg.org/css-page-floats/
dbaron@16542 12 Previous Version: http://www.w3.org/TR/2015/WD-css-page-floats-3-20150915/
johanneswilm@15215 13 Editor: Johannes Wilm, Vivliostyle, [email protected]
johanneswilm@15215 14 Former Editor: H&aring;kon Wium Lie, Opera Software, [email protected]
johanneswilm@15349 15 Abstract: This document describes floats that move to the top or bottom of content
johanneswilm@15349 16 Abstract: passages. This feature has traditionally been used in print
johanneswilm@15349 17 Abstract: publications in which figures and photos are moved to the top or bottom
johanneswilm@15349 18 Abstract: of columns or pages, along with their captions.
johanneswilm@15349 19 Abstract: This draft describes how to achieve this effects for floats within pages,
johanneswilm@15349 20 Abstract: columns, regions and elements.
mail@15781 21 Ignored Terms: near, 3em, intrude, top-corner, bottom-corner, left, right, both, element, none, floats, inline, max-width, max-height
johanneswilm@15215 22 </pre>
johanneswilm@15215 23
johanneswilm@15215 24
johanneswilm@15215 25 <h2 id="overview">Overview</h2>
johanneswilm@15215 26
mail@15653 27 <em>This section is not normative.</em>
mail@15653 28
johanneswilm@15349 29 This specification adds new keywords on the 'float' property.
johanneswilm@15215 30
johanneswilm@15390 31 This document allows to specify whether a <a>float</a> floats to align with a
johanneswilm@15390 32 <a>float reference</a> inline box, column, region or page. In the case of floats
mail@15938 33 with a reference <a>fragmentation container</a>, placement can be deferred to a
mail@15938 34 subsequent <a>fragmentation container</a> with the <em>float-defer</em> properties.
johanneswilm@15349 35
mail@15781 36 New values on the 'clear' property add further ways of refining layouts.
johanneswilm@15349 37
johanneswilm@15349 38 The way contents wrap around floats can be controlled by changing the value of
mail@15781 39 the 'wrap-flow' property which initially is set to 'both' for page floats.
johanneswilm@15349 40
johanneswilm@15349 41 <p class="issue">
mail@15781 42 Page floats as defined here work with different types of fragmentation types
johanneswilm@15349 43 (columns, regions, pages) as well as container elements. The specification
johanneswilm@15349 44 is no longer specific to print or to pages.
johanneswilm@15349 45 At the same time, inline floats and page floats differ in many ways, and it may
johanneswilm@15349 46 (or may not) be a good idea to separate the two entirely.
johanneswilm@15349 47 Therefore, the name <em>CSS Page Floats</em> should probably be replaced with
johanneswilm@15349 48 a more appropriate name.
johanneswilm@15390 49 </div>
johanneswilm@15349 50
johanneswilm@15349 51
johanneswilm@15349 52 <h2 id="terms">
johanneswilm@15349 53 Terminology</h2>
johanneswilm@15349 54
johanneswilm@15349 55 <dl export>
johanneswilm@15390 56 <dt><dfn>Float</dfn>
johanneswilm@15349 57 <dd>
johanneswilm@15349 58 An element which has float set to something else than none.
mail@16623 59 <dt><dfn>Inline float</dfn>
mail@16623 60 <dd>
mail@16623 61 A float which has float set to inline.
mail@16623 62 <dt><dfn>Page float</dfn>
mail@16623 63 <dd>
mail@16623 64 A float which has float set to something else than inline or none.
johanneswilm@15349 65 <dt><dfn>Float block formatting context</dfn>
johanneswilm@15349 66 <dd>
johanneswilm@15349 67 The block formatting context which is generated by a float and which contains
johanneswilm@15349 68 its contents.
johanneswilm@15349 69 <dt><dfn>Float anchor</dfn>
johanneswilm@15349 70 <dd>
johanneswilm@15349 71 The float anchor is the point in the flow where the float had appeared had
mail@15651 72 it not been a float and instead had been an empty inline element with no
mail@15651 73 margins, borders or padding.
johanneswilm@15349 74 <dt><dfn>Float containing block formatting context</dfn>
johanneswilm@15349 75 <dd>
mail@16623 76 The block formatting context inside of which an float is embedded.
mail@15653 77 <dt><dfn>Initial float reference</dfn>
mail@15653 78 <dd>
mail@15781 79 The entity to which the float is aligned initially, before float
mail@15781 80 placement takes place.
johanneswilm@15349 81 <dt><dfn>Float reference</dfn>
johanneswilm@15349 82 <dd>
johanneswilm@15349 83 The entity to which the float is aligned.
mail@16032 84 <dt><dfn>Not overlapping</dfn>
mail@16032 85 <dd>
mail@16019 86 Two elements are not overlapping if the margin box of one element is not
mail@16019 87 overlapping the margin box of the other element.
johanneswilm@15349 88 </dl>
johanneswilm@15349 89
johanneswilm@15215 90 <h2 id="floating">
johanneswilm@15349 91 Floating to the inline-start/inline-end and block-start/block-end</h2>
johanneswilm@15215 92
johanneswilm@15215 93 <p>
johanneswilm@15351 94 Floating elements can float to the start or end of the <a>float anchor</a>'s line or
johanneswilm@15351 95 block, specified by the 'float' attribute. The floats are aligning to the start
johanneswilm@15351 96 or end of a <a>float reference</a>, specified by the 'float-reference' attribute. The
johanneswilm@15351 97 <a>float reference</a> can be the <a>float anchor</a>'s line box, column, region or page.
johanneswilm@15349 98
johanneswilm@15349 99
johanneswilm@15390 100 <h3 id="float-reference-property">The 'float-reference' property</h3>
johanneswilm@15351 101
johanneswilm@15351 102 <pre class="propdef">
johanneswilm@15351 103 Name: float-reference
johanneswilm@15351 104 Value: inline | column | region | page
johanneswilm@15351 105 Initial: inline
johanneswilm@15351 106 Applies to: all elements.
johanneswilm@15351 107 Inherited: no
johanneswilm@15351 108 Percentages: N/A
johanneswilm@15351 109 Media: visual
johanneswilm@15351 110 Computed value: as specified.
johanneswilm@15351 111 Animatable: no
johanneswilm@15351 112 </pre>
johanneswilm@15351 113
johanneswilm@15351 114 <dl dfn-for="float-reference" dfn-type="value">
johanneswilm@15351 115
johanneswilm@15351 116 <dt><dfn>inline</dfn>
johanneswilm@15351 117 <dd>
johanneswilm@15351 118 The <a>float reference</a> is the line box of the <a>float anchor</a>.
johanneswilm@15351 119
johanneswilm@15351 120 The <a>float containing block formatting context</a> is the same as that of the
johanneswilm@15351 121 <a>float anchor</a>.
johanneswilm@15351 122
mail@16623 123 The float is an <a>inline float</a>.
mail@16623 124
johanneswilm@15351 125 <dt><dfn>column</dfn>
johanneswilm@15351 126 <dd>
johanneswilm@15351 127 The <a>float reference</a> is the column in a multi column environment in
johanneswilm@15351 128 which the <a>float anchor</a> is placed. If the <a>float anchor</a> is not
johanneswilm@15351 129 inside a column, the <a>float reference</a> is the line box of the <a>float
johanneswilm@15351 130 anchor</a>.
johanneswilm@15351 131
johanneswilm@15390 132 The <a>float containing block formatting context</a> is a new block formatting
johanneswilm@15390 133 context with the same dimensions and placement as the <a>float reference</a>.
mail@16623 134
mail@16623 135 The float is a <a>page float</a>.
mail@16623 136
johanneswilm@15351 137 <dt><dfn>region</dfn>
johanneswilm@15351 138 <dd>
johanneswilm@15351 139 The <a>float reference</a> is the region in a region-chain within which the
johanneswilm@15351 140 <a>float anchor</a> is placed. If the <a>float anchor</a> is not inside a
johanneswilm@15351 141 region, the <a>float reference</a> is the line box of the <a>float
johanneswilm@15351 142 anchor</a>.
johanneswilm@15351 143
johanneswilm@15351 144 The <a>float containing block formatting context</a> is a new block formatting
johanneswilm@15390 145 context with the same dimensions and placement as the <a>float reference</a>.
johanneswilm@15351 146
mail@16623 147 The float is a <a>page float</a>.
mail@16623 148
johanneswilm@15351 149 <dt><dfn>page</dfn>
johanneswilm@15351 150 <dd>
johanneswilm@15351 151 The <a>float reference</a> of the float is the page within which the <a>float
johanneswilm@15351 152 anchor</a> is placed. If the <a>float anchor</a> is not inside a page, the
johanneswilm@15351 153 <a>float reference</a> is the line box of the <a>float anchor</a>.
johanneswilm@15351 154
johanneswilm@15351 155 The <a>float containing block formatting context</a> is a new block formatting
mail@16623 156 context with the same dimensions and placement as the <a>float reference</a>.
mail@16623 157
mail@16623 158 The float is a <a>page float</a>.
johanneswilm@15351 159 </dl>
johanneswilm@15351 160
johanneswilm@15351 161 <div class="issue">
johanneswilm@15390 162 The <a>float containing block formatting context</a> having the same dimensions
johanneswilm@15390 163 as the <a>float reference</a> means that all floats that are not inline floats
johanneswilm@15390 164 cannot move outside of their float references. Is this wanted?
johanneswilm@15390 165 </div>
johanneswilm@15390 166
johanneswilm@15390 167 <div class="issue">
mail@16623 168 It is not possible to specify a block element which element to use as the
mail@16623 169 reference element. This has been requested.
johanneswilm@15351 170
johanneswilm@15351 171 Maybe something like:
johanneswilm@15351 172
mail@16196 173 <pre><code>
johanneswilm@15351 174 &lt;style>
johanneswilm@15351 175 .float {
johanneswilm@15351 176 float-reference: float-container;
johanneswilm@15351 177 }
johanneswilm@15351 178
johanneswilm@15351 179 #container {
johanneswilm@15351 180 float-container: true;
johanneswilm@15351 181 }
johanneswilm@15351 182 &lt;/style>
johanneswilm@15351 183
johanneswilm@15351 184 &lt;div id="container">
johanneswilm@15351 185 &lt;p>First paragraph&lt;span class="float">FLOAT&lt;/span>&lt;/p>
johanneswilm@15351 186
johanneswilm@15351 187 &lt;p>Second paragraph
johanneswilm@15351 188 &lt;span class="inline-block">[&lt;span class="float">FLOAT&lt;/span>] &lt;/span>
johanneswilm@15351 189 And some more text&lt;/p>
johanneswilm@15351 190 &lt;/div>
mail@16196 191 </code></pre>
johanneswilm@15351 192
johanneswilm@15351 193 This should float both floats with reference to the &lt;div id="container">
johanneswilm@15351 194 element, rather than the &lt;P> and inline &lt;SPAN> elements.
johanneswilm@15351 195
johanneswilm@15351 196 </div>
johanneswilm@15351 197
johanneswilm@15390 198 <h3 id="float-property">The 'float' property</h3>
johanneswilm@15390 199
johanneswilm@15390 200 <pre class="propdef">
johanneswilm@15390 201 Name: float
johanneswilm@15390 202 Value: block-start | block-end | inline-start | inline-end | snap-block | snap-inline | left | right | top | bottom | none
johanneswilm@15390 203 Initial: none
johanneswilm@15390 204 Applies to: all elements.
johanneswilm@15390 205 Inherited: no
johanneswilm@15390 206 Percentages: N/A
johanneswilm@15390 207 Media: visual
johanneswilm@15390 208 Computed value: as specified.
johanneswilm@15390 209 Animatable: no
johanneswilm@15390 210 </pre>
johanneswilm@15390 211
johanneswilm@15390 212 <dl dfn-for="float" dfn-type="value">
johanneswilm@15390 213
johanneswilm@15390 214 <dt><dfn>inline-start</dfn>
johanneswilm@15390 215 <dd>
mail@16753 216 If the <a>float reference</a> is a line box, the element generates a box that
mail@16753 217 is floated to the line-start outer edge of the <a>float reference</a> and
mail@16753 218 content flows on the line-end side of the box.
mail@16753 219
mail@16753 220 If the <a>float reference</a> is not a line box, the element generates a box
mail@16753 221 that is floated to the line-start and block-start outer edges of the <a>float
mail@16753 222 reference</a>.
johanneswilm@15390 223
johanneswilm@15390 224 <dt><dfn>inline-end</dfn>
johanneswilm@15390 225 <dd>
mail@16753 226 If the <a>float reference</a> is a line box, the element generates a box that
mail@16753 227 is floated to the line-ebd outer edge of the <a>float reference</a> and
mail@16753 228 content flows on the line-start side of the box.
mail@16753 229
mail@16753 230 If the <a>float reference</a> is not a line box, the element generates a box
mail@16753 231 that is floated to the line-end and block-end outer edges of the <a>float
mail@16753 232 reference</a>.
johanneswilm@15390 233
johanneswilm@15390 234 <dt><dfn>block-start</dfn>
johanneswilm@15390 235 <dd>
johanneswilm@15390 236 If the <a>float reference</a> is a line box, block-start behaves like
johanneswilm@15390 237 inline-start.
johanneswilm@15390 238
johanneswilm@15390 239 If the <a>float reference</a> is not a line box, the element generates a box
johanneswilm@15390 240 that is floated to the block-start and line-start outer edges of the <a>float
johanneswilm@15390 241 reference</a>.
johanneswilm@15390 242
johanneswilm@15390 243 The initial value of the <a>max-width</a> or <a>max-height</a> property that
johanneswilm@15390 244 refers to the <a>inline size</a> of the float is '100%'.
johanneswilm@15390 245
mail@15938 246 Content flows on the block-end side of the box.
johanneswilm@15390 247
johanneswilm@15390 248 <dt><dfn>block-end</dfn>
johanneswilm@15390 249 <dd>
johanneswilm@15390 250 If the <a>float reference</a> is a line box, block-end behaves like inline-end.
johanneswilm@15390 251
johanneswilm@15390 252 If the <a>float reference</a> is not a line box, the element generates a box
mail@16753 253 that is floated to the block-end and line-end outer edges of the <a>float
johanneswilm@15390 254 reference</a>.
johanneswilm@15390 255
johanneswilm@15390 256 The initial value of the <a>max-width</a> or <a>max-height</a> property that
johanneswilm@15390 257 refers to the <a>inline size</a> of the float is '100%'.
johanneswilm@15390 258
mail@15938 259 Content flows on the block-start side of the box.
johanneswilm@15390 260
johanneswilm@15390 261 <dt><dfn>left</dfn>
johanneswilm@15390 262
johanneswilm@15390 263 <dd>
mail@15650 264 If the <a>float reference</a> is a line box, behaves like inline-start or
mail@15650 265 inline-end, whichever corresponds to line-left for the float reference.
mail@15650 266
mail@16623 267 Otherwise, behaves like block-end, inline-start or inline-end depending on
mail@16623 268 the float containing block’s 'direction' and 'writing-mode'.
johanneswilm@15390 269
johanneswilm@15390 270 <dt><dfn>right</dfn>
johanneswilm@15390 271
johanneswilm@15390 272 <dd>
mail@15650 273 If the <a>float reference</a> is a line box, behaves like inline-start or
mail@15650 274 inline-end, whichever corresponds to line-right for the float reference.
mail@15650 275
mail@16623 276 Otherwise, behaves like block-start, inline-start or inline-end depending on
mail@16623 277 the float containing block’s 'direction' and 'writing-mode'.
johanneswilm@15390 278
johanneswilm@15390 279 <dt><dfn>top</dfn>
johanneswilm@15390 280
johanneswilm@15390 281 <dd>
johanneswilm@15390 282 Behave like block-start or inline-start depending on the float
johanneswilm@15390 283 containing block’s 'direction' and 'writing-mode'.
johanneswilm@15390 284
johanneswilm@15390 285 <dt><dfn>bottom</dfn>
johanneswilm@15390 286
johanneswilm@15390 287 <dd>
johanneswilm@15390 288 Behave like block-end or inline-end depending on the float
johanneswilm@15390 289 containing block’s 'direction' and 'writing-mode'.
johanneswilm@15390 290
mail@15938 291 <dt><dfn>snap-block(&lt;length> [, start | end | near ]?)</dfn>
johanneswilm@15390 292 <dd>
mail@16623 293 Has no effect if the element is an <a>inline float</a>.
mail@16623 294
mail@16623 295 If the element is a <a>page float</a>, it makes the element float to the
mail@16623 296 start or the end of the block if it naturally appears within a certain
mail@16623 297 distance from either one. The length value(s) specifies the maximum
mail@16623 298 distance from the start/end that an element must be within in order to be
mail@16623 299 floated; one length value specifies the distance from both the start and
mail@16623 300 the end, two length values specify the distance from the start and end,
mail@16623 301 respectively.
johanneswilm@15390 302
johanneswilm@15390 303 The optional keyword value specifies where the element is floated: start,
johanneswilm@15390 304 end, or the nearest of the two. The initial value is 'near'. If 'near'
johanneswilm@15390 305 is in effect and the element is within the specified distance both from
johanneswilm@15390 306 the start and the end, end wins.
johanneswilm@15390 307
johanneswilm@15390 308 <dt><dfn>snap-block</dfn>
mail@16196 309 <dd>same as <code>snap-block(2em, near)</code>
johanneswilm@15390 310
mail@15938 311 <dt><dfn>snap-inline(&lt;length> [, left | right | near ]?)</dfn>
johanneswilm@15390 312 <dd>
mail@16623 313 Has no effect if the element is an <a>inline float</a>.
mail@16623 314
mail@16623 315 If the element is a <a>page float</a>, it makes the element float to the
mail@16623 316 line start or line end if it naturally appears within a certain distance
mail@16623 317 from the start or end of the line. The length value(s) specifies the
mail@16623 318 maximum distance from the start/end that an element must be within in
mail@16623 319 order to be floated; one length value specifies the distance from both the
mail@16623 320 start and the end, two length values specify the distance from the start
mail@16623 321 and end, respectively.
johanneswilm@15390 322
johanneswilm@15390 323 The optional keyword value specifies where the element is floated: line
johanneswilm@15390 324 start, line end, or the nearest of the two. The initial value is 'near'.
johanneswilm@15390 325 If 'near' is in effect and the element is within the specified distance
johanneswilm@15390 326 both from the start and the end, end wins.
johanneswilm@15390 327
johanneswilm@15390 328
johanneswilm@15390 329 <dt><dfn>snap-inline</dfn>
mail@16196 330 <dd>same as <code>snap-inline(2em, near)</code>
johanneswilm@15390 331
johanneswilm@15390 332 <dt><dfn>none</dfn>
johanneswilm@15390 333 <dd>The box is not floated.
johanneswilm@15390 334
johanneswilm@15390 335 </dl>
johanneswilm@15390 336
johanneswilm@15390 337 <div class="issue">
johanneswilm@15390 338 There is currently no way to float into a combination of directions (top right,
johanneswilm@15390 339 right top, left bottom, bottom left, etc.).
johanneswilm@15390 340 </div>
johanneswilm@15390 341
johanneswilm@15390 342
johanneswilm@15390 343 <div class="example">
johanneswilm@15390 344 Float figure to top of reference column:
johanneswilm@15390 345
johanneswilm@15390 346 <pre>
johanneswilm@15390 347 .figure { float-reference: column; float: top }
johanneswilm@15390 348 </pre>
johanneswilm@15390 349
johanneswilm@15390 350 <img alt="sample rendering" src="images/7.png">
johanneswilm@15390 351 </div>
johanneswilm@15390 352
johanneswilm@15390 353 <div class="example">
johanneswilm@15390 354 In this example a block-start float that does not fill the entire <a>inline size</a>
johanneswilm@15390 355 of the float reference is placed at the start of the block and line.
johanneswilm@15390 356
johanneswilm@15390 357 <pre>
johanneswilm@15390 358 .figure { float-reference: column; float: block-start; width: 50% }
johanneswilm@15390 359 </pre>
johanneswilm@15390 360
johanneswilm@15390 361 <img alt="sample rendering" src="images/block_line_start.png">
johanneswilm@15390 362 </div>
johanneswilm@15390 363
johanneswilm@15390 364 <div class="example">
johanneswilm@15390 365 In this example, a figure naturally appears close to a column break. There is
johanneswilm@15390 366 not enough space for the figure in the first column, and it is therefore placed
johanneswilm@15390 367 in the second column, leaving white space at the bottom of the first column.
johanneswilm@15390 368
johanneswilm@15390 369 <img alt="sample rendering" src="images/23.png">
johanneswilm@15390 370
johanneswilm@15390 371 To avoid the white space, the image can be floated to the nearest edge (in the
johanneswilm@15390 372 block direction):
johanneswilm@15390 373
johanneswilm@15390 374 <pre>
johanneswilm@15390 375 .figure { float-reference: column; float: snap-block }
johanneswilm@15390 376 </pre>
johanneswilm@15390 377
johanneswilm@15390 378 In this example, the figure is already at the nearest edge, so it does not
johanneswilm@15390 379 move. However, floats allow subsequent content to be displayed before the
johanneswilm@15390 380 float and the white space can therefore be filled:
johanneswilm@15390 381
johanneswilm@15390 382 <img alt="sample rendering" src="images/7.png">
johanneswilm@15390 383 </div>
johanneswilm@15390 384
johanneswilm@15390 385 <div class="example">
johanneswilm@15390 386
johanneswilm@15390 387 In this example, two figures naturally appear in the text flow:
johanneswilm@15390 388
johanneswilm@15390 389 <img alt="sample rendering" src="images/20.png">
johanneswilm@15390 390
johanneswilm@15390 391 A typographer would typically try to avoid single lines of text above/below
johanneswilm@15390 392 figures, which can be achieved with:
johanneswilm@15390 393
johanneswilm@15390 394 <pre>
johanneswilm@15390 395 div.figure { float-reference: column; float: snap-block(1.5em) }
johanneswilm@15390 396 </pre>
johanneswilm@15390 397
johanneswilm@15390 398 The length value specifies the reach of the snap function; in this example the
johanneswilm@15390 399 second figure is affected, but not the first.
johanneswilm@15390 400 </div>
johanneswilm@15390 401
johanneswilm@15390 402 <div class="example">
johanneswilm@15390 403
johanneswilm@15390 404 In this example, two figures naturally appear in the text flow:
johanneswilm@15390 405
johanneswilm@15390 406 <img alt="sample rendering" src="images/20.png">
johanneswilm@15390 407
johanneswilm@15390 408 To make the figures snap to the nearest edges, this code can be applied:
johanneswilm@15390 409
johanneswilm@15390 410 <pre>
johanneswilm@15390 411 div.figure { float-reference: column; float: snap-block(2.5em) }
johanneswilm@15390 412 </pre>
johanneswilm@15390 413
johanneswilm@15390 414 The resultant rendering is:
johanneswilm@15390 415
johanneswilm@15390 416 <img alt="sample rendering" src="images/22.png">
johanneswilm@15390 417
johanneswilm@15390 418 </div>
johanneswilm@15390 419
johanneswilm@15390 420
johanneswilm@15390 421 <div class="example">
johanneswilm@15390 422 In this example, tables will snap to the top/bottom if the top/bottom of the
johanneswilm@15390 423 border box is closer than '3em' from the top/bottom of the float-reference
johanneswilm@15390 424 which is a block element.
johanneswilm@15390 425
johanneswilm@15390 426 <pre>
johanneswilm@15390 427 table { float: snap }
johanneswilm@15390 428 table { float: snap-block(3em) }
johanneswilm@15390 429 table { float: snap-block(3em, bottom) }
johanneswilm@15390 430 table { float: snap-block(3em 2em, bottom) }
johanneswilm@15390 431 </pre>
johanneswilm@15390 432
johanneswilm@15390 433 </div>
johanneswilm@15390 434
johanneswilm@15351 435 <div class="note">
mail@15781 436 More examples with regions as <a>float reference</a>s needed.
johanneswilm@15351 437 </div>
johanneswilm@15351 438
johanneswilm@15215 439
johanneswilm@15349 440 <h2 id="clearing_page_floats">
johanneswilm@15349 441 The 'clear' property</h2>
johanneswilm@15215 442
johanneswilm@15349 443 <pre class="propdef">
johanneswilm@15349 444 Name: clear
johanneswilm@15351 445 Value: inline-start | inline-end | block-start | block-end | left | right | top | bottom | none
johanneswilm@15349 446 Initial: none
johanneswilm@15349 447 Applies to: block-level elements, floats, regions, pages
johanneswilm@15349 448 Inherited: no
johanneswilm@15349 449 Percentages: N/A
johanneswilm@15349 450 Media: visual
johanneswilm@15349 451 Computed value: as specified.
johanneswilm@15349 452 Animatable: no
johanneswilm@15349 453 </pre>
johanneswilm@15215 454
johanneswilm@15349 455 To prevent stacking of floats, the 'clear' property can be used:
johanneswilm@15215 456
johanneswilm@15349 457 <dl dfn-for="clear" dfn-type="value">
johanneswilm@15215 458
johanneswilm@15351 459 <dt><dfn>inline-start</dfn>
johanneswilm@15351 460 <dd>
mail@15781 461 If applied to an inline float, requires that the block-start outer edge of
mail@15781 462 the box comes after the block-end outer edge of any inline-start-floats
mail@15781 463 with an inline-start-float-reference that resulted from elements earlier
mail@15781 464 in the source document.
johanneswilm@15351 465
mail@16623 466 If applied to a <a>page float</a>, the <a>float reference</a> in which the
mail@16623 467 page float is placed will be seen as full when determining whether it can
mail@16623 468 host subsequent page floats that float in the inline-start direction.
johanneswilm@15351 469
johanneswilm@15351 470 <dt><dfn>inline-end</dfn>
johanneswilm@15351 471 <dd>
mail@16623 472 If applied to a block-level element or an <a>inline float</a>, requires
mail@16623 473 that the block-start outer edge of the box comes after the block-end outer
mail@16623 474 edge of any inline-end-floats with an inline-end-float-reference that
mail@16623 475 resulted from elements earlier in the source document.
johanneswilm@15351 476
mail@16623 477 If applied to a <a>page float</a>, the <a>float reference</a> in which the
mail@16623 478 page float is placed will be seen as full when determining whether it can
mail@16623 479 host subsequent page floats that float in the inline-end direction.
johanneswilm@15351 480
johanneswilm@15351 481
johanneswilm@15351 482 <dt><dfn>block-start</dfn>
johanneswilm@15351 483 <dd>
mail@16623 484 If applied to a block-level element or an <a>inline float</a>, behaves like
mail@16623 485 inline-start.
johanneswilm@15351 486
mail@16623 487 If applied to a page float, the <a>float reference</a> in which the page
mail@16623 488 float is placed will be seen as full when determining whether it can host
mail@15781 489 subsequent page floats that float in the block-start direction.
johanneswilm@15351 490
johanneswilm@15351 491 <dt><dfn>block-end</dfn>
johanneswilm@15351 492
johanneswilm@15351 493 <dd>
mail@16623 494 If applied to a block-level element or an <a>inline float</a>, behaves
mail@16623 495 like inline-end.
johanneswilm@15351 496
mail@15938 497 If applied to a page float, the <a>float reference</a> in which the page float
mail@15781 498 is placed will be seen as full when determining whether it can host
mail@15781 499 subsequent page floats that float in the block-end direction.
johanneswilm@15351 500
johanneswilm@15349 501 <dt><dfn>left</dfn>
johanneswilm@15351 502
johanneswilm@15349 503 <dd>
johanneswilm@15351 504 Behave like block-end, inline-start or inline-end depending on the float
johanneswilm@15351 505 containing block’s 'direction' and 'writing-mode'.
johanneswilm@15215 506
johanneswilm@15349 507 <dt><dfn>right</dfn>
johanneswilm@15351 508
johanneswilm@15349 509 <dd>
johanneswilm@15351 510 Behave like block-start, inline-start or inline-end depending on the float
johanneswilm@15351 511 containing block’s 'direction' and 'writing-mode'.
johanneswilm@15215 512
johanneswilm@15349 513 <dt><dfn>top</dfn>
johanneswilm@15351 514
johanneswilm@15349 515 <dd>
johanneswilm@15351 516 Behave like block-start or inline-start depending on the float
johanneswilm@15351 517 containing block’s 'direction' and 'writing-mode'.
johanneswilm@15215 518
johanneswilm@15349 519 <dt><dfn>bottom</dfn>
johanneswilm@15215 520
johanneswilm@15215 521 <dd>
johanneswilm@15351 522 Behave like block-end or inline-end depending on the float
johanneswilm@15351 523 containing block’s 'direction' and 'writing-mode'.
johanneswilm@15215 524
mail@16623 525 <dt><dfn>both-inline</dfn>
mail@16623 526
mail@16623 527 <dd>
mail@16623 528 Behave like inline-start and inline-end.
mail@16623 529
mail@16623 530 <dt><dfn>both-block</dfn>
mail@16623 531
mail@16623 532 <dd>
mail@16623 533 Behave like block-start and block-end.
mail@16623 534
mail@16623 535 <dt><dfn>both</dfn>
mail@16623 536
mail@16623 537 <dd>
mail@16623 538 Behave like both-inline.
mail@16623 539
mail@16623 540 <dt><dfn>all</dfn>
mail@16623 541
mail@16623 542 <dd>
mail@16623 543 Behave like both-block and both-inline.
mail@16623 544
johanneswilm@15215 545 </dl>
johanneswilm@15215 546
johanneswilm@15215 547
johanneswilm@15215 548 <div class="example">
johanneswilm@15215 549 In this example, the two figures may appear in the same column:
johanneswilm@15215 550
johanneswilm@15215 551 <pre>
johanneswilm@15349 552 .figure { float-reference: column; float: bottom; clear: none }
johanneswilm@15215 553
johanneswilm@15215 554 &ltdiv class=figure>&lt;/div>
johanneswilm@15215 555 &ltdiv class=figure>&lt;/div>
johanneswilm@15215 556 </pre>
mail@16196 557 <img alt="sample rendering" src="images/16.png">
johanneswilm@15215 558 </div>
johanneswilm@15215 559
johanneswilm@15215 560 <div class="example">
johanneswilm@15215 561 In this example, the two figures will appear in different columns:
johanneswilm@15215 562
johanneswilm@15215 563 <pre>
johanneswilm@15349 564 .figure { float-reference: column; float: bottom; clear: bottom }
johanneswilm@15215 565
johanneswilm@15215 566 &ltdiv class=figure>&lt;/div>
johanneswilm@15215 567 &ltdiv class=figure>&lt;/div>
johanneswilm@15215 568 </pre>
johanneswilm@15215 569
mail@16196 570 <img alt="sample rendering" src="images/17.png">
johanneswilm@15215 571 </div>
johanneswilm@15215 572
johanneswilm@15215 573
johanneswilm@15215 574 <div class="example">
mail@15781 575 In this example, the two figures may appear at the bottom of the same column
mail@15781 576 due to clearing only at the top:
johanneswilm@15215 577
johanneswilm@15215 578 <pre>
johanneswilm@15349 579 .figure { float-reference: column; float: bottom; clear: top }
johanneswilm@15215 580
johanneswilm@15215 581 &ltdiv class=figure>&lt;/div>
johanneswilm@15215 582 &ltdiv class=figure>&lt;/div>
johanneswilm@15215 583 </pre>
johanneswilm@15215 584
mail@16196 585 <img alt="sample rendering" src="images/16.png">
johanneswilm@15215 586 </div>
johanneswilm@15215 587
johanneswilm@15215 588 <div class="example">
mail@15781 589 In this example, the two figures will appear in different columns due to
mail@15781 590 clearing at the bottom:
johanneswilm@15215 591
johanneswilm@15215 592 <pre>
johanneswilm@15349 593 .figure { float-reference: column; float: bottom; clear: bottom }
johanneswilm@15215 594
johanneswilm@15215 595 &ltdiv class=figure>&lt;/div>
johanneswilm@15215 596 &ltdiv class=figure>&lt;/div>
johanneswilm@15215 597 </pre>
johanneswilm@15215 598
mail@16196 599 <img alt="sample rendering" src="images/17.png">
johanneswilm@15215 600 </div>
johanneswilm@15215 601
johanneswilm@15215 602
johanneswilm@15215 603 <div class="example">
mail@15781 604 In this example, the two figures end up the top corner of two different
mail@15781 605 pages:
johanneswilm@15215 606
johanneswilm@15215 607 <pre>
johanneswilm@15349 608 .figure { float-reference: page; float: top; clear: top }
johanneswilm@15215 609
johanneswilm@15215 610 &ltdiv class=figure>&lt;/div>
johanneswilm@15215 611 &ltdiv class=figure>&lt;/div>
johanneswilm@15215 612 </pre>
johanneswilm@15215 613
johanneswilm@15215 614 </div>
johanneswilm@15215 615
johanneswilm@15215 616 <div class="example">
johanneswilm@15215 617 In this example, the two figures request different positions, and they may
johanneswilm@15215 618 therefore end up in the same column:
johanneswilm@15215 619
johanneswilm@15215 620 <pre>
johanneswilm@15349 621 .figure.one { float-reference: column; float: top; clear: top }
johanneswilm@15349 622 .figure.two { float-reference: column; float: bottom; clear: bottom }
johanneswilm@15215 623
johanneswilm@15215 624 &ltdiv class="figure one">&lt;/div>
johanneswilm@15215 625 &ltdiv class="figure two">&lt;/div>
johanneswilm@15215 626 </pre>
johanneswilm@15215 627
johanneswilm@15215 628 </div>
johanneswilm@15215 629
mail@16623 630 <h2 id="deferring_floats">Deferring page floats</h2>
johanneswilm@15215 631
mail@16623 632 Users can influence the placement of a <a>page float</a> by deferring them to
mail@16623 633 another <a>fragmentation container</a> than where the <a>float anchor</a> is
mail@16623 634 placed.
johanneswilm@15215 635
mail@16623 636 A float that is an <a>inline float</a> cannot be deferred.
mail@16623 637
mail@16623 638 Float deferring assigns an <a>initial float reference</a>, yet float stacking
mail@16623 639 can lead page floats being moved to a subsequent <a>fragmentation container</a>
mail@16623 640 if their <a>initial float reference</a> lacks the space to host them.
johanneswilm@15390 641
mail@16023 642 The 'float-defer' property is introduced to control deferring floats:
johanneswilm@15215 643
johanneswilm@15390 644 <h3 id="float-defer-property">The 'float-defer' property</h3>
johanneswilm@15215 645
johanneswilm@15349 646 <pre class="propdef">
johanneswilm@15349 647 Name: float-defer
johanneswilm@15349 648 Value: &ltinteger> | last | none
johanneswilm@15349 649 Initial: none
johanneswilm@15349 650 Applies to: floats
johanneswilm@15349 651 Inherited: no
johanneswilm@15349 652 Percentages: N/A
johanneswilm@15349 653 Media: visual
johanneswilm@15349 654 Computed value: as specified.
johanneswilm@15349 655 Animatable: no
johanneswilm@15349 656 </pre>
johanneswilm@15215 657
johanneswilm@15349 658
mail@16623 659 This property specifies whether the <a>initial float reference</a> of a <a>page
mail@16623 660 float</a> is the <a>fragmentation container</a> in which the <a>float anchor</a>
mail@16623 661 is placed after previous page floats have been placed, or in another one.
mail@16623 662
mail@16623 663 This property is ignored if the element is an <a>inline float</a>.
mail@16623 664
mail@16623 665 Values are:
johanneswilm@15349 666
johanneswilm@15349 667 <dl>
johanneswilm@15349 668 <dt>none
mail@15938 669 <dd>The <a>initial float reference</a> is the <a>fragmentation container</a> in which the
mail@15938 670 <a>float anchor</a> is placed after all previous page floats have been placed.
johanneswilm@15349 671
johanneswilm@15349 672 <dt>&lt;integer>
johanneswilm@15349 673 <dd>
mail@15938 674 A positive integer value indicates that the <a>initial float reference</a> of
mail@15938 675 the page float should be Nth <a>fragmentation container</a> of the `fragmentation
mail@15781 676 flow`, where N is the value of the `float-defer` property plus the order
mail@15938 677 number of the <a>fragmentation container</a> in which the <a>float anchor</a> is placed
mail@15781 678 after all previous page floats have been placed within the given
mail@15938 679 <a>fragmentation context</a>. If N is larger than the order number of the last
mail@15938 680 <a>fragmentation container</a> within the given <a>fragmentation context</a> at the time of
mail@15938 681 assignment, then N is the order number of the last <a>fragmentation container</a>
mail@15938 682 within the given <a>fragmentation context</a>.
johanneswilm@15349 683
mail@15938 684 A negative integer value indicates that the <a>initial float reference</a> of
mail@16023 685 the page float should be a <a>fragmentation container</a> of the
mail@16023 686 <a>fragmentation context</a>, counting backward from the end, so that -1
mail@16023 687 is the last <a>fragmentation container</a>, -2 is the next-to-last, etc. .
mail@16023 688 In the case of a negative integer value, the <a>initial float reference</a> is the
mail@16023 689 Nth <a>fragmentation container</a> of the <a>fragmentation context</a>, where N is 1
mail@16023 690 plus the order number of the last <a>fragmentation container</a> within the given
mail@16023 691 <a>fragmentation context</a> after all previous page floats have been placed plus
mail@16023 692 the value of the `float-defer` property.
johanneswilm@15349 693
mail@15781 694 Zero is the same as `none`.
mail@15781 695
mail@16023 696 If the value of the `float-defer` property would cause the <a>initial float
mail@16023 697 reference</a> to be an inexistent <a>fragmentation container</a>, the property
mail@16023 698 is interpreted as if it were zero.
mail@16023 699
mail@16023 700 <p class="note">
mail@16023 701 Negative float-defer values put the initial float reference a certain number
mail@16023 702 to be a certain amount of fragmentation containers from the last fragmentation
mail@16023 703 container at the time of of the placement. Subsequent page float stacking
mail@16023 704 can mean that a page float is being placed in a later fragmentation container
mail@16023 705 (a page float with float-defer set to -3 can end up being placed in the
mail@16023 706 last fragmentation container), and later page floats may mean that new
mail@16023 707 fragmentation containers are added, so that the a fragmentation container
mail@16023 708 that previously was Nth last fragmentation container within a fragmentation
mail@16023 709 context now is the N+Xth last. Additional fragmentation container(s) that
mail@16023 710 are added after the page float was placed, will not cause the page float
mail@16023 711 to be moved.
mail@16023 712
mail@15781 713 <dt>last
mail@15781 714 <dd>
mail@15938 715 The <a>initial float reference</a> is the last <a>fragmentation container</a> within
mail@15938 716 the given <a>fragmentation context</a> after all previous page floats have been
mail@15781 717 placed.
mail@15781 718
mail@15781 719 </dl>
mail@15781 720
mail@15781 721 <div class="example">
mail@15781 722 Float figure to the top of the region that follows the region in which
mail@15938 723 the <a>float anchor</a> is placed:
johanneswilm@15215 724
johanneswilm@15215 725 <pre>
mail@15781 726 .figure { float-reference: region }
johanneswilm@15349 727 .figure { float: top }
johanneswilm@15349 728 .figure { float-defer: 1 }
johanneswilm@15215 729 </pre>
johanneswilm@15215 730
mail@15781 731 </div>
johanneswilm@15215 732
mail@15781 733 <div class="example">
mail@15781 734 Float figure to the top of the next-to-last column:
johanneswilm@15215 735
johanneswilm@15215 736 <pre>
mail@15781 737 .figure { float-reference: column; float: top; float-defer: -2 }
johanneswilm@15215 738 </pre>
johanneswilm@15215 739
mail@15781 740 <img alt="sample rendering" src="images/7.png">
mail@15781 741 </div>
johanneswilm@15215 742
mail@15781 743 <div class="example">
mail@15781 744 Float figure to the top of the last page:
johanneswilm@15349 745
johanneswilm@15349 746 <pre>
johanneswilm@15349 747 .figure { float-reference: page }
johanneswilm@15349 748 .figure { float: top }
johanneswilm@15349 749 .figure { float-defer: -1 }
johanneswilm@15349 750 </pre>
mail@15781 751 </div>
johanneswilm@15349 752
mail@15781 753 <div class="example">
mail@15781 754 Float figure to the top of the last column:
johanneswilm@15349 755
johanneswilm@15349 756 <pre>
johanneswilm@15349 757 .figure { float-reference: column }
johanneswilm@15349 758 .figure { float: top }
johanneswilm@15349 759 .figure { float-defer: last }
johanneswilm@15349 760 </pre>
johanneswilm@15349 761
mail@15781 762 </div>
johanneswilm@15349 763
mail@15781 764 <div class="example">
mail@15781 765 Float figure to top of the last column:
johanneswilm@15349 766
mail@15781 767 <pre>
mail@15781 768 .figure { float-reference: column; float: top; float-defer: last }
mail@15781 769 </pre>
johanneswilm@15349 770
mail@15781 771 <img alt="sample rendering" src="images/6.png">
mail@15781 772 </div>
mail@15781 773
mail@16623 774 <h2 id="wrapping-around-page-floats">Wrapping around page floats</h2>
johanneswilm@15349 775
mail@16623 776 Page floats have their 'wrap-flow' property set to 'both' initially and are
mail@16623 777 treated like exclusions. This specification does not make any further
mail@16623 778 specification about wrapping contents around page floats.
johanneswilm@15349 779
johanneswilm@15390 780 <div class="issue">
johanneswilm@15390 781 Should the 'wrap-flow' really be set to both, or should the flow be restricted
johanneswilm@15390 782 to only be on one side?
johanneswilm@15390 783 </div>
johanneswilm@15215 784
johanneswilm@15215 785 <h2 id="the-float_offset-property">The 'float-offset' property</h2>
johanneswilm@15215 786
johanneswilm@15349 787 <pre class="propdef">
johanneswilm@15349 788 Name: float-offset
mail@15938 789 Value: &lt;length> | &lt;percentage>
johanneswilm@15349 790 Initial: 0
johanneswilm@15349 791 Applies to: floats
johanneswilm@15349 792 Inherited: no
mail@15938 793 Percentages: see prose
johanneswilm@15349 794 Media: visual
mail@15938 795 Computed value: one absolute length
johanneswilm@15349 796 Animatable: no
johanneswilm@15349 797 </pre>
johanneswilm@15215 798
mail@16623 799 This property pushes a <a>page float</a> in direction opposite of the where it has been
johanneswilm@15349 800 floated with 'float'.
johanneswilm@15215 801
mail@16623 802 If the element is an <a>inline float</a>, this property is ignored.
mail@16623 803
mail@16623 804 This property can only influence a <a>page float</a> along an axis along which
mail@16623 805 it has been floated.
mail@15938 806
mail@15938 807 <dl>
mail@15938 808 <dt>&lt;percentage></dt>
mail@15938 809 <dd>
mail@15938 810 Percentage values are computed according to this formula:
mail@15938 811
mail@15938 812 <pre>
mail@15938 813 (containing-block-width - float-width) * percentage
mail@15938 814 (containing-block-height - float-height) * percentage
mail@15938 815 </pre>
mail@15938 816 </dd>
mail@15938 817 </dl>
mail@15938 818
johanneswilm@15215 819 <div class="example">
johanneswilm@15215 820
johanneswilm@15215 821 <pre>
johanneswilm@15215 822 img {
johanneswilm@15349 823 float-reference: column;
johanneswilm@15215 824 float: left;
johanneswilm@15349 825 float-offset: 2em;
johanneswilm@15215 826 }
johanneswilm@15215 827 </pre>
johanneswilm@15215 828
johanneswilm@15215 829 In this example, the image is floated to the left. Therefore, 'float-offset'
johanneswilm@15349 830 may only push the element to the right.
johanneswilm@15215 831
johanneswilm@15215 832 </div>
johanneswilm@15215 833
johanneswilm@15215 834
johanneswilm@15215 835 <div class="example">
johanneswilm@15215 836
johanneswilm@15349 837 <pre>
johanneswilm@15349 838 img {
johanneswilm@15349 839 float-reference: column;
johanneswilm@15215 840 float: right;
johanneswilm@15215 841 float-offset: 5px;
johanneswilm@15215 842 }
johanneswilm@15215 843 </pre>
johanneswilm@15215 844
johanneswilm@15215 845 <img alt="sample rendering" src="images/14.png">
johanneswilm@15215 846
johanneswilm@15215 847 </div>
johanneswilm@15215 848
mail@16625 849 <!--div class="example">
johanneswilm@15215 850 Pull quotes are often centered in a column. In this example, the pull quote is
johanneswilm@15215 851 floated to the right, and then pushed back into the center.
johanneswilm@15215 852
mail@16196 853 <img alt="sample rendering" src="images/region_pullquote.png">
johanneswilm@15215 854
johanneswilm@15215 855 <pre>
johanneswilm@15215 856 .pullquote {
johanneswilm@15349 857 float-reference: region;
johanneswilm@15215 858 float: right;
johanneswilm@15215 859 float-offset: 50%; /* 50% centers the box */
johanneswilm@15215 860 }
johanneswilm@15215 861 </pre>
johanneswilm@15215 862
mail@16625 863 </div-->
johanneswilm@15215 864
mail@15938 865
mail@15938 866 <h2 id="page-float-placement">Page float placement</h2>
mail@15938 867
mail@16019 868 The order of page floats placement is determined by the following rules:
mail@15939 869
mail@15939 870 <ol>
mail@15941 871 <li>
mail@16019 872 All page floats with 'float-reference' set to `page` are placed, in
mail@16019 873 document order, before those with 'float-reference' set to `region` and
mail@16019 874 `column`.
mail@15941 875 <li>
mail@15941 876 Thereafter, page floats with 'float-reference' set to `column` and `region`
mail@16019 877 are placed in document order.
mail@15941 878 </li>
mail@15939 879 </ol>
mail@15939 880
mail@15939 881 The placement of a single page float is a process that has to be terminated
mail@15938 882 entirely before the placement of a subsequent page float can be initiated. The
mail@15938 883 placement process consists of the following steps:
mail@15938 884
mail@15938 885 <ol>
mail@15938 886
mail@15938 887 <li>Determine the <a>initial float reference</a> by considering the
mail@15938 888 <a>fragmentation container</a> in which the <a>float anchor</a> is placed and
mail@15938 889 the `float-defer` property of the page float. The <a>float reference</a> is
mail@15938 890 initially set to be the same as the <a>initial float reference</a>.</li>
mail@15938 891
mail@15938 892 <li>Determine if the given <a>float reference</a> has enough space or can be
mail@15939 893 expanded to host the page float, if the rules of <a href="#float-stacking">
mail@15939 894 float stacking</a> and <a href="#float-reference-growth">float reference
mail@15939 895 growth</a> are to be followed. If this is not the case, and the <a>float
mail@15939 896 reference</a> is not the last <a>fragmentation container</a> within the given
mail@15939 897 <a>fragmentation context</a>, then make the following <a>fragmentation
mail@15939 898 container</a> within the given <a>fragmentation context</a> the <a>float
mail@15939 899 reference</a>. Repeat this step until the <a>float reference</a> can be
mail@15939 900 expanded enough to host the page float or it is the last <a>fragmentation
mail@15939 901 container</a> within the given <a>fragmentation context</a>.</li>
mail@15938 902
mail@15938 903 <li>If the <a>float reference</a> is the last <a>fragmentation container</a> within
mail@15938 904 the given <a>fragmentation context</a>, and it has not enough space and cannot be
mail@15938 905 expanded to host the page float, then do the following:</li>
mail@15938 906
mail@15938 907 <ol>
mail@15938 908 <li>If the <a>fragmentation context</a> allows for the addition of another
mail@15938 909 <a>fragmentation container</a> and an additional <a>fragmentation container</a>
mail@15939 910 would have the needed size to host the page float, a new <a>fragmentation
mail@15939 911 container</a> is added to the end of the <a>fragmentation context</a>. The
mail@15939 912 <a>float reference</a> is set the newly created <a>fragmentation
mail@15939 913 container</a>.</li>
mail@15938 914
mail@15938 915 <li>Otherwise, if the <a>fragmentation container</a> is a region, then the
mail@15938 916 'regionOverset` attribute of the <a>fragmentation container</a> is set to
mail@15938 917 `overset`.
mail@15938 918 </ol>
mail@15938 919
mail@15938 920 <li>The page float is placed in the <a>float reference</a> according to the rules
mail@15938 921 of 'float stacking' and 'float reference growth'.</li>
mail@15938 922
mail@15938 923 </ol>
mail@15938 924
mail@15938 925 <h3 id="float-reference-growth">Float reference growth</h3>
mail@15938 926
mail@15938 927 Float references can grow up to the their `max-height` and `max-width` or their
mail@15938 928 `available size`, whichever is the lowest, in order to accommodate page floats.
mail@15938 929
mail@16623 930 <h3 id="float-stacking">Rules for page float stacking</h3>
mail@15938 931
mail@15938 932 Page floats are stacked within a given <a>float reference</a> in the order of their
mail@15938 933 placement and in the direction of the inline- and flow-directions of the
mail@16019 934 <a>fragmentation context</a> while <a>not overlapping</a> with any other page
mail@16019 935 floats with the same <a>float reference</a> and by keeping a distance N between
mail@16019 936 the page float's margin edge and the padding edge of the <a>float reference</a>
mail@16019 937 as well as between the page float's margin edge and the margin edge of the last
mail@16019 938 previously placed page float with the same <a>float reference</a> and the same
mail@16623 939 'float' value, where N is the 'float-offset' value of the page float.
mail@16623 940
mail@16623 941 For the purpose of calculating whether enough space is available for a page floats
mail@16623 942 within the <a>float reference</a>, it is assumed that the page floats in the block
mail@16623 943 directions fill the entire line size of the <a>float reference</a> and page floats
mail@16623 944 in the inline direction fill the entire block size of the <a>float reference</a>.
mail@16623 945
mail@16623 946 For the purpose of placement, page floats in the block-start direction are also
mail@16623 947 placed at the inline-start edge of the float reference and vice versa, and page
mail@16623 948 floats in the block-end direction are placed at the inline-end edge of the float
mail@16623 949 reference and vice versa.
mail@15938 950
mail@15938 951 If the page float has a defined 'clear'-value, then the <a>float reference</a> in
mail@15938 952 which the page float is placed is closed for all subsequent page floats that
mail@15938 953 floating in the direction specified by the 'clear'-value.
mail@15938 954
mail@15938 955 <p class="issue">
mail@16623 956 We can effectively currently float to two corners: inline-start/block-start and
mail@16623 957 inline-end/block-end. We should augment this with the option to have a secondary
mail@16623 958 float direction to allow basic 2D floating.
johanneswilm@15215 959
mail@15763 960
mail@15653 961 <h2 id="relation_to_absolutely_positioned_exclusions">
mail@15653 962 Floats and absolutely positioned exclusions</h2>
johanneswilm@15215 963
mail@15653 964 Floats and absolutely positioned exclusions share some common traits, but in the
mail@15653 965 case of inline floats they are not the same. Floats that are not inline floats
mail@15653 966 should behave the same as absolutely positioned exclusions with positions and
mail@15653 967 sizes manually set to prevent overlap between floats and to prevent floats from
mail@15653 968 moving beyond the edges of the float reference, with the float reference being
mail@15653 969 grown as much as needed up to its maximum extend to accommodate all containing
mail@15653 970 floats.
mail@15653 971
mail@15653 972 <h3 id="inline_floats_and_absolutely_positioned_exclusions">
mail@15653 973 Differences between inline floats and absolutely positioned elements</h3>
mail@15653 974
mail@15653 975 <em>This section is not normative.</em>
mail@15653 976
mail@15653 977 <p>
mail@15653 978 Inline floats and absolutely positioned elements are both out-of-flow elements.
mail@15653 979 Absolutely positioned elements that are also exclusions can imitate many of
mail@15653 980 the features of floats.
mail@15653 981
mail@15653 982 <p>
mail@15653 983 However, in the case of inline floats, the block formatting context that
mail@15653 984 contains them (the <a>float containing block formatting context</a>) is
mail@15653 985 required to include the area occupied by the float, which is not a requirement
mail@15653 986 for absolutely positioned elements.
mail@15653 987
mail@15653 988 <div class="example">
mail@15653 989 An inline float inside a <a>float containing block formatting context</a> given
mail@15653 990 by a display-inline-block element. The element, which has a green border, is
mail@15653 991 expanded to include the brown float.
mail@15653 992
mail@16196 993 <pre><code>
mail@15653 994 &lt;style>
mail@15653 995 .float {
mail@15653 996 float: left;
mail@15653 997 margin: 5px;
mail@15653 998 }
mail@15653 999 .border {
mail@15653 1000 border: 3px solid black;
mail@15653 1001 margin: 5px;
mail@15653 1002 }
mail@15653 1003 #outer {
mail@15653 1004 border: 1px solid green;
mail@15653 1005 display: inline-block;
mail@15653 1006 }
mail@15653 1007 canvas {
mail@15653 1008 background-color: brown;
mail@15653 1009 }
mail@15653 1010 p {
mail@15653 1011 margin: 5px;
mail@15653 1012 }
mail@15653 1013 &lt;/style>
mail@15653 1014 &lt;div id="outer">
mail@15653 1015 &lt;p class="border">
mail@15653 1016 &lt;span class="float border">
mail@15653 1017 &lt;canvas width="100" height="100"/>
mail@15653 1018 &lt;/span>
mail@15653 1019 First paragraph.
mail@15653 1020 &lt;/p>
mail@15653 1021 &lt;p class="border">
mail@15653 1022 Second paragraph and some more text.
mail@15653 1023 &lt;/p>
mail@15653 1024 &lt;/div>
mail@16196 1025 </code></pre>
mail@15653 1026
mail@15653 1027 <img alt="sample rendering" src="images/float_containing_context.png">
mail@15653 1028
mail@15653 1029 In comparison, the below is the same HTML, but the float is replaced by an
mail@15653 1030 absolutely positioned element that is also an exclusion. The <a>float
mail@15653 1031 containing block formatting context</a> is still given by a
mail@15653 1032 display-inline-block element. However, the element, marked by a green border,
mail@15653 1033 does not expand to include the brown, absolutely positioned element.
mail@15653 1034
mail@16196 1035 <pre><code>
mail@15653 1036 &lt;style>
mail@15653 1037 .float {
mail@15653 1038 position: absolute;
mail@15653 1039 top: 8px;
mail@15653 1040 left: 8px;
mail@15653 1041 wrap-flow: both;
mail@15653 1042 }
mail@15653 1043 .border {
mail@15653 1044 border: 3px solid black;
mail@15653 1045 margin: 5px;
mail@15653 1046 }
mail@15653 1047 #outer {
mail@15653 1048 border: 1px solid green;
mail@15653 1049 display: inline-block;
mail@15653 1050 position: relative;
mail@15653 1051 }
mail@15653 1052 canvas {
mail@15653 1053 background-color: brown;
mail@15653 1054 }
mail@15653 1055 &lt;/style>
mail@15653 1056 &lt;div id="outer">
mail@15653 1057 &lt;p class="border">
mail@15653 1058 &lt;span class="float border">
mail@15653 1059 &lt;canvas width="100" height="100"/>
mail@15653 1060 &lt;/span>
mail@15653 1061 First paragraph.
mail@15653 1062 &lt;/p>
mail@15653 1063 &lt;p class="border">
mail@15653 1064 Second paragraph and some more text.
mail@15653 1065 &lt;/p>
mail@15653 1066 &lt;/div>
mail@16196 1067 </code></pre>
mail@15653 1068
mail@15653 1069 <img alt="sample rendering" src="images/positioned_containing_context.png">
mail@15653 1070
mail@15653 1071 </div>
mail@15653 1072
johanneswilm@15349 1073 <h2 id="overconstrained-page-floats">Overconstrained floats</h2>
johanneswilm@15215 1074
johanneswilm@15215 1075 In many cases, the specified values on these properties cannot be honored.
johanneswilm@15215 1076
johanneswilm@15215 1077 <div class="example">
johanneswilm@15215 1078
johanneswilm@15215 1079 The number of columns is limited, and high values therefore cannot be honored:
johanneswilm@15215 1080
johanneswilm@15215 1081 <pre>
johanneswilm@15349 1082 .figure { float-reference: column; float: top; float-defer: 1000 }
johanneswilm@15215 1083 </pre>
johanneswilm@15215 1084
johanneswilm@15215 1085 </div>
johanneswilm@15215 1086
johanneswilm@15215 1087 <div class="example">
johanneswilm@15215 1088 A narrow screen may only have room for one column, in which case this request
johanneswilm@15215 1089 cannot be honored:
johanneswilm@15215 1090
johanneswilm@15215 1091 <pre>
johanneswilm@15349 1092 .figure { float-reference: column; float: top; float-defer: -5 }
johanneswilm@15215 1093 </pre>
johanneswilm@15215 1094
johanneswilm@15215 1095 </div>
johanneswilm@15215 1096
johanneswilm@15215 1097 <div class="example">
johanneswilm@15215 1098 In long documents, all content cannot fit on the last page, and this rule
johanneswilm@15215 1099 therefore cannot be honored:
johanneswilm@15215 1100
johanneswilm@15215 1101 <pre>
johanneswilm@15349 1102 p { float-reference: page; float: top; float-defer: last }
johanneswilm@15215 1103 </pre>
johanneswilm@15215 1104
johanneswilm@15215 1105 </div>
johanneswilm@15215 1106
johanneswilm@15349 1107 Floats are processed in the order they appear in the source. However, the
johanneswilm@15349 1108 visual order of floats may not be the same as the source order.
johanneswilm@15215 1109
johanneswilm@15215 1110 <div class="example">
johanneswilm@15215 1111 Consider this code:
johanneswilm@15215 1112
johanneswilm@15215 1113 <pre>
johanneswilm@15349 1114 .one { float-reference: page; float: top; float-defer: last }
johanneswilm@15349 1115 .two { float-reference: column; float: top; clear: column }
johanneswilm@15215 1116
johanneswilm@15215 1117 &lt;div class=one>&lt;/div>
johanneswilm@15215 1118 &lt;div class=two>&lt;/div>
johanneswilm@15215 1119 </pre>
johanneswilm@15215 1120
johanneswilm@15215 1121 In this example, the first element requests to appear on the last page, while
johanneswilm@15215 1122 the second element requests to appear in the natural column. If the natural
johanneswilm@15215 1123 column of the second element appears on a page before the last page, the second
johanneswilm@15215 1124 element will appear visually before the first.
johanneswilm@15215 1125
johanneswilm@15215 1126 </div>
johanneswilm@15215 1127
johanneswilm@15215 1128
johanneswilm@15215 1129 <div class="example">
johanneswilm@15215 1130
johanneswilm@15215 1131 Consider this code:
johanneswilm@15215 1132
johanneswilm@15215 1133 <pre>
johanneswilm@15349 1134 .one { float-reference: page; float: top; float-defer: last }
johanneswilm@15349 1135 .two { float-reference: page; float: top; clear: page; }
johanneswilm@15215 1136
johanneswilm@15215 1137 &lt;div class=one>&lt;/div>
johanneswilm@15215 1138 &lt;div class=two>&lt;/div>
johanneswilm@15215 1139 </pre>
johanneswilm@15215 1140
johanneswilm@15215 1141 If all content can fit on one page, the first page will also be the last page.
johanneswilm@15215 1142 The first element is processed first and is placed on top of the first page.
mail@15938 1143 Then the second element is processed. It requests a clear top, something which is
johanneswilm@15215 1144 not possible on the first page. Therefore, a second page is created and the
johanneswilm@15215 1145 first element is moved there. Even if the first element requests to be on the
johanneswilm@15215 1146 last page, it will not appear there.
johanneswilm@15215 1147
johanneswilm@15215 1148 </div>
johanneswilm@15215 1149
johanneswilm@15215 1150 When resolving over-constrained layouts, the order of importance for defined
johanneswilm@15215 1151 goals are:
johanneswilm@15215 1152
johanneswilm@15215 1153 <ol>
mail@15767 1154 <li>honor 'clear: top/bottom'
johanneswilm@15349 1155 <li>honor 'float-defer'
johanneswilm@15215 1156 <li>honor 'float: top/bottom'
johanneswilm@15215 1157 <li>display all content (as described by other CSS properties)
johanneswilm@15215 1158 <li>keep the number of pages to a minimum
johanneswilm@15215 1159 </ol>
johanneswilm@15215 1160
johanneswilm@15215 1161 <h2 class="no-num" id="acks">
johanneswilm@15215 1162 Acknowledgments</h2>
johanneswilm@15215 1163
johanneswilm@15215 1164 This specification is made possible by input from
mail@16627 1165 Rossen Atanassov,
johanneswilm@15215 1166 Tab Atkins Jr.,
johanneswilm@15215 1167 David Baron,
johanneswilm@15215 1168 Lars Erik Bolstad,
johanneswilm@15215 1169 Bert Bos,
johanneswilm@15215 1170 Mike Bremford,
mail@16627 1171 Dave Cramer,
johanneswilm@15215 1172 Michael Day,
johanneswilm@15215 1173 Werner Donn&eacute;,
johanneswilm@15215 1174 Brady Duga,
johanneswilm@15215 1175 James Elmore,
johanneswilm@15215 1176 Elika Etemad,
johanneswilm@15215 1177 Michel Fortin,
johanneswilm@15215 1178 Daniel Glazman,
johanneswilm@15215 1179 Melinda Grant,
johanneswilm@15215 1180 Ian Hickson,
johanneswilm@15215 1181 Laurens Holst,
johanneswilm@15215 1182 Brad Kemper,
johanneswilm@15215 1183 Toru Kawakubo,
johanneswilm@15215 1184 Rune Lillesveen,
johanneswilm@15215 1185 Peter Linss,
johanneswilm@15215 1186 Cameron McCormack,
johanneswilm@15215 1187 Paul E. Merrell,
johanneswilm@15215 1188 Del Merritt,
johanneswilm@15215 1189 Markus Mielke,
johanneswilm@15215 1190 Kelly Miller,
johanneswilm@15215 1191 Alex Mogilevsky,
johanneswilm@15215 1192 Peter Moulder,
johanneswilm@15215 1193 Shinyu Murakami,
johanneswilm@15215 1194 Michel Onoff,
johanneswilm@15215 1195 Anton Prowse,
johanneswilm@15215 1196 Liam R E Quin,
johanneswilm@15215 1197 Jacob Grundtvig Refstrup,
johanneswilm@15215 1198 Florian Rivoal,
johanneswilm@15215 1199 Christian Roth,
johanneswilm@15215 1200 Allan Sandfeld Jensen,
johanneswilm@15215 1201 Simon Sapin,
mail@16627 1202 Alan Stearns,
johanneswilm@15215 1203 Morten Stenshorne,
johanneswilm@15215 1204 Philip Taylor,
johanneswilm@15215 1205 Ian Tindale,
johanneswilm@15215 1206 Ladd Van Tol,
mail@16627 1207 Lea Verou,
johanneswilm@15215 1208 Tarquin (Mark) Wilton-Jones,
johanneswilm@15215 1209 Steve Zilles,
johanneswilm@15215 1210 Tantek &#xC7;elik
johanneswilm@15215 1211 and the CSS Working Group members.

mercurial