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/

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

mercurial