8000 csswg-drafts/css-page-floats/#Overview.src.html# at 05f4647f7c676c4ce61cac6aa05aa57e8878a592 · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
1426 lines (1037 loc) · 35 KB

File metadata and controls

1426 lines (1037 loc) · 35 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>CSS Page Floats</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../default.css">
<link href="http://www.w3.org/StyleSheets/TR/W3C-[STATUS].css" rel=stylesheet type="text/css">
<style type="text/css">
.example img { display: block }
.example { background: #ddd }
body { line-height: 1.3 }
.remove, .unimplemented { display: none }
table.string-set-example { font-family: monospace; border-collapse: collapse }
table.string-set-example div.pre {
width: 12em; white-space: pre;
}
table.string-set-example td {
padding: 0.3em;
border: thin solid black
}
</style>
<body>
<div class="head">
<!--logo-->
<h1>CSS Page Floats</h1>
<h2 class="no-num no-toc" id="w3c-working">[LONGSTATUS] [DATE]</h2>
<dl>
<dt>This version:</dt>
<dd><a href="[VERSION]">http://www.w3.org/TR/[YEAR]/[STATUS]-css3-gcpm-[CDATE]/</a></dd>
<dt>Latest version:
<dd><a href="http://www.w3.org/TR/css3-gcpm/">http://www.w3.org/TR/css-page-floats/</a>
<!--
<dt>Previous version:
<dd><a href="http://www.w3.org/TR/2010/WD-css-page-floats/">
http://www.w3.org/TR/2010/WD-css-page-floats/</a>
-->
<dt>Feedback:</dt>
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-gcpm%5D%20feedback">www-style@w3.org</a> with subject line &ldquo;<kbd>[css-page-floats] <var>&hellip; message topic &hellip;</var></kbd>&rdquo; (<a rel="discussion" href="http://lists.w3.org/Archives/Public/www-style/">archives</a>)
<dt>Editor:
<dd>H&aring;kon Wium Lie, Opera Software, howcome@opera.com
</dl>
<!--copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id=abstract>Abstract</h2>
<p>This module describes features often used in printed publications. Figures and photos are often moved to the top or bottom of columns and pages, along with their captions. Some elements (e.g., call-outs) push aside other content in the flow of text, and sometimes one column is given a different styling than others. This draft describes how to achieve these effects, both on paper and screens.
<h2 class="no-num no-toc">Status of this document</h2>
<!--begin-status-->
<!--end-status-->
<p>This WD contains functionality that the CSS WG finds interesting and useful. The described functionality used to be part of the [[GCPM]] draft
<h2 class="no-num no-toc"><a name="contents">Table of contents</a></h2>
<!--begin-toc-->
<p>[If you keep the &lt;!--comment--> the table of contents will be
included here automatically.]</p>
<!--end-toc-->
<h2 class="no-num">Introduction</h2>
<p>(This section is not normative.)
<p>This specification describes features often used in printed
publications.
<h2>Page floats</h2>
<p>In page-based layouts, images and figures are often displayed at
the top or bottom of pages. This specificaton adds new keywords on the
'float' property to create <em>page floats</em>. A page float can
float inside its natural column/page, or its placement can be deferred
to a following column/page with the <em>float-defer</em> properties.
Page floats can be set to span several columns, thereby supporting
commonly used newspaper layouts. New values on the 'clear' property
adds further ways of refining layouts with page floats.
<p class=note>Not all multicol elements are constrained by the page
box. Therefore, a more accurate term for page floats may be <em>column
floats</em> as all of them are constrained by the column box. However,
in most cases, page floats seems like a better term.
<h3>Floating to the top/bottom: top, bottom, snap</h3>
<p>These new keywords on 'float' have been added:
<dl>
<dt>top
<dd>The float is floated to the top of the column
<dt>bottom
<dd>The float is floated to the bottom of the column
<!--
<dt>top-corner
<dd>the box is floated to the top of the last column (in the inline direction) that fits inside the multicol element on the same page.
<dt>bottom-corner
<dd>similar to 'top-corner', exept the box is floated to the bottom
-->
<dt>snap(&lt;length> &lt;length>? [, top | bottom | near ]?)
<dd><p>Makes the element float to the top or bottom if it naturally appears within a certain distance from the top or bottom. The length value(s) specifies the maxium distance from the top/bottom that an element must be within in order to be floated; one length value specifies the distance from both the top and the bottom, two length values specify the distance from the top and bottom, respectively.
<p>The optional keyword value specifies where the element is floated: top, bottom, or the nearest of the two. The initial value is 'near'. If 'near' is in effect and the element is within the specified distance both from the top and the bottom, bottom wins.
<p>An element is considered to be a float if it has a snap() value, even if the element does not appear within the specified distance. This way, it can be determined whether an element is float or not without laying out the document.
<dt>snap
<dd>same as <tt>snap(2em, near)</tt>
</dl>
<p>These new keywords only apply in paged media; in continous media
declarations with these keywords are ignored.
<p>Elements with any of these new keywords are called 'page floats'.
Each page float has a <em>natural column</em>, which is the column
where the element would have started to appears it it was not a float.
Also, each page float has a <em>natural page</em>, which is the page
where the element would have started if the was not a float. Unless
other constrained by lack of space or other float-* properties, page
floats should appear in their natural column on the natural page.
<div class=example>
<p>Float figure to top of natural column:
<pre>
.figure { float: top }
</pre>
<img alt="sample rendering" src=7.png>
</div>
<div class=example>
<pre>
.figure { float: top; width: 50% }
</pre>
<img alt="sample rendering" src=7b.png>
</div>
<div class=example>
<p>In this example, a figure naturally appears close to a column break. There is not enough space for the figure in the first column, and it is therefore placed in the second column, leaving white space at the bottom of the first column.</p>
<img alt="sample rendering" src=23.png>
<p>To avoid the white space, the image can be floated to the nearest edge (in the block direction):</p>
<pre>
.figure { float: snap }
</pre>
<p>In this example, the figure is already at the nearest edge, so it does not move. However, page floats allow subsequent content to be displayed before the page float and the white space can therefore be filled:</p>
<img alt="sample rendering" src=7.png>
</div>
<div class=example>
<p>In this example, two figures naturally appear in the text flow:</p>
<img alt="sample rendering" src=20.png>
<p>A typographer would typically try to avoid single lines of text above/below figures, which can be achieved with:
<pre>
div.figure { float: snap(1.5em) }
</pre>
<p>The length value specifies the reach of the snap function; in this example the second figure is affected, but not the first.
</div>
<div class=example>
<p>In this example, two figures naturally appear in the text flow:</p>
<img alt="sample rendering" src=20.png>
<p>To make the figures snap to the nearest edges, this code can be applied:
<pre>
div.figure { float: snap(2.5em) }
</pre>
<p>The resultant rendering is:</p>
<img alt="sample rendering" src=22.png>
</div>
<div class=example>
<p>Float figure to top of the natural column, spanning all columns:
<pre>
.figure { float: top; column-span: all }
</pre>
<img alt="sample redering" src=15.png>
</div>
<div class=example>
<p>In this example, tables will snap to the top/bottom if the top/bottom of the border box is closer than '3em' from the top/bottom of the page/column.
<pre>
table { float: snap }
table { float: snap(3em) }
table { float: snap(3em, bottom) }
table { float: snap(3em 2em, bottom) }
</pre>
</div>
<p class=issue>Do numeric values, to represent line numbers, make sense, like for orphans/widows?
<h3>Spanning columns</h3>
<p>The 'column-span' property is extended with integer values so that elements can span several columns. If the specified integer value is equal to, or larger than the number of columns in the multicol element, the number of columns spanned will be the same as if 'column-span: all' had been specified.
<div class=example>
<p>In this example, a commonly used newspaper layout is easily described:
<pre>
body { columns: 3 }
img.A { column-span: 2; width: 100% } /* image spans two columns */
.one { column-span: 2 } /* lead paragraph spans two columns */
</pre>
<img alt="sample rendering" src=regions.png>
</div>
<p>Further, the 'page' value is added to 'column-span' so that the page (and not the column or element) becomes the reference.
<div class=example>
<p>In this example, the footer is floated to the bottom of the last page (and not the bottom of the article element):
<pre>
footer { float: bottom; column-span: page }
&lt;article>
...
&lt;footer>...&lt;.footer>
&lt;/article>
</pre>
</div>
<p class=issue>An alternative way to express this would be to add a separate propertye, e.g., <code>float-reference: column | multicol | page</code></dfn>
<h3>Deferring floats: float-defer-column, float-defer-page</h3>
<p>A page float can be deferred to a following column/page with these new properties:
<h4>'float-defer-column'</h4>
<table class=propdef>
<tr>
<td><em>Name:</em>
<td><dfn>float-defer-column</dfn>
<tr>
<td><em>Value:</em>
<td>&ltinteger> | last | none
<tr>
<td><em>Initial:</em>
<td>none
<tr>
<td><em>Applies to:</em>
<td>page floats
<tr>
<td><em>Inherited:</em>
<td>no
<tr>
<td><em>Percentages:</em>
<td>N/A
<tr>
<td><em>Media:</em>
<td>visual
<tr>
<td><em>Computed&nbsp;value:</em>
<td>specified value
</table>
<h4>'float-defer-page'</h4>
<table class=propdef>
<tr>
<td><em>Name:</em>
<td><dfn>float-defer-page</dfn>
<tr>
<td><em>Value:</em>
<td>&ltinteger> | last | none
<tr>
<td><em>Initial:</em>
<td>none
<tr>
<td><em>Applies to:</em>
<td>page floats
<tr>
<td><em>Inherited:</em>
<td>no
<tr>
<td><em>Percentages:</em>
<td>N/A
<tr>
<td><em>Media:</em>
<td>visual
<tr>
<td><em>Computed&nbsp;value:</em>
<td>specified value
</table>
<p>These properties specify whether page floats should appear in their natural column/page, or in a following column/page. Values are:
<dl>
<dt>none
<dd>the page float appears in the natural column/page
<dt>&lt;integer>
<dd>A positive integer value indicates that the page float should be displayed in a following column/page. A negative integer value indicates that the page float should be displayed in a following column/page, counted from the last column/page. When counting columns, the starting point is the last column of the multicol element on the natural page. When counting pages, the starting point is the last page of the multicol element.
</dl>
<div class=example>
<p>Float figure to the top of the column that follows the natural column:
<pre>
.figure { float: top }
.figure { float-defer-column: 1 }
</pre>
</div>
<div class=example>
<p>Float figure to the top of the next-to-last column:
<pre>
.figure { float: top; float-defer-column: -1 }
</pre>
<img alt="sample rendering" src=7.png>
</div>
<div class=example>
<p>Float figure to top of the last column of the multicol element on the current page:
<pre>
.figure { float: top; float-defer-column: last }
</pre>
<img alt="sample rendering" src=6.png>
</div>
<div class=example>
<p>In combination with 'column-span', the figure is floated to the top corner of the multicol element on that page:
<pre>
.figure { float: top; column-span: 2; float-defer-column: last; width: 100% }
</pre>
<img alt="sample rendering" src=8.png>
</div>
<div class=example>
<p>Float figure to the top of the second column, spanning two columns:
<pre>
.figure {
float: top; column-span: 2;
float-defer-column: 1;
}
</pre>
<img alt="sample rendering" src=18.png>
</div>
<div class=example>
<p>Float figure to the top right, leaving one full column:
<pre>
.figure {
float: top; column-span: 2;
float-defer-column: -1;
}
</pre>
<img alt="sample rendering" src=18.png>
<p>Given that there are four columnn, the same layout would be achived with this code:
<pre>
.figure {
float: top; column-span: 2;
float-defer-column: 1;
}
</pre>
</div>
<div class=example>
<p>Float figure to the top of the first column on the next-to-last page:
<pre>
.figure { float: top }
.figure { float-defer-page: -1 }
</pre>
</div>
<div class=example>
<p>Float figure to the top of the next-to-last column on the next-to-last page:
<pre>
.figure { float: top }
.figure { float-defer-column: -1 }
.figure { float-defer-page: -1 }
</pre>
</div>
<dt>last
<dd>The page float should be displayed in the last colum, or on the last page.
<div class=example>
<p>Float figure to the top of the last column on the natural page:
<pre>
.figure { float: top }
.figure { float-defer-column: last }
</pre>
<img alt="sample rendering" src=6.png>
</div>
<div class=example>
<p>Float figure to the last column on the last page:
<pre>
.figure { float: top }
.figure { float-defer-column: last }
.figure { float-defer-page: last }
</pre>
</div>
<dt>none
<dd>The page floats should appear in their natural column/page, if possible.
</dl>
<p>Zero is not a legal value.
<h3>Clearing page floats</h3>
<p>Page floats may request to not be stacked, or to be the only page float on a page/column through new values on the 'clear' property:
<dl>
<dt>top/bottom
<dd>The page float requests to be the only page float at the top/bottom of the column. If there is already a page float at the requested position, the page float is moved to the next column which does not have a page float in the requested position.
<dt>column
<dd>The page float requests to be the only page float in the column. If there is already another page float on the page, the page float is moved to the next page which does not have a page float.
<dt>page
<dd>The page float requests to be the only page float on the page. If there is already another page float on the page, the page float is moved to the next page which does not have a page float.
</dl>
<div class=example>
<p>In this example, the two figures may appear in the same column:
<pre>
.figure { float: bottom; clear: none }
&ltdiv class=figure>&lt;/div>
&ltdiv class=figure>&lt;/div>
</pre>
<img src="16.png">
</div>
<div class=example>
<p>In this example, the two figures will appear in different columns:
<pre>
.figure { float: bottom; clear: column }
&ltdiv class=figure>&lt;/div>
&ltdiv class=figure>&lt;/div>
</pre>
<img src="17.png">
</div>
<div class=example>
<p>In this example, the two figures may appear at the bottom of the same column due to clearing only at the top:
<pre>
.figure { float: bottom; clear: top }
&ltdiv class=figure>&lt;/div>
&ltdiv class=figure>&lt;/div>
</pre>
<img src="16.png">
</div>
<div class=example>
<p>In this example, the two figures will appear in different columns due to clearing at the bottom:
<pre>
.figure { float: bottom; clear: bottom }
&ltdiv class=figure>&lt;/div>
&ltdiv class=figure>&lt;/div>
</pre>
<img src="17.png">
</div>
<div class=example>
<p>In this example, the two figures end up the top corner of two different pages:
<pre>
.figure { float: top; float-defer-column: last; clear: page }
&ltdiv class=figure>&lt;/div>
&ltdiv class=figure>&lt;/div>
</pre>
</div>
<div class=example>
<p>In this example, the two figures request different positions, and
they may therefore end up in the same column:
<pre>
.figure.one { float: top; clear: top }
.figure.two { float: bottom; clear: bottom }
&ltdiv class="figure one">&lt;/div>
&ltdiv class="figure two">&lt;/div>
</pre>
</div>
<h3>Floating inside and outside pages</h3>
<p>Two allow content to flow to the inside and outside of a page, these keywords are added to the 'float' property:
<dl>
<dt>inside
<dd>On a right page, this value is synonymous with 'left'. On a left page, this value is synonymous with 'right'.
<dt>outside
<dd>On a left page, this value is synonymous with 'left', On a right page, this value is synonymous with 'right'.
</dl>
<p>These new values do not create page floats, the are simply aliases for 'left' and 'right'.
<div class=example>
<pre>
.figure { float: outside }
</pre>
</div>
<p class=issue>Should there be a way to combine float: top/bottom with left/right?
<p class=issue>Should there be a way to delete page floats that end up lonesome on pages?
<h3>Wrapping around page floats</h3>
<table class=propdef>
<tr>
<td><em>Name:</em>
<td><dfn>float-wrap</dfn>
<tr>
<td><em>Value:</em>
<td>none | wrap
<tr>
<td><em>Initial:</em>
<td>none
<tr>
<td><em>Applies to:</em>
<td>page floats
<tr>
<td><em>Inherited:</em>
<td>no
<tr>
<td><em>Percentages:</em>
<td>N/A
<tr>
<td><em>Media:</em>
<td>visual
<tr>
<td><em>Computed&nbsp;value:</em>
<td>specified value
</table>
<p>This property indicates whether other content may wrap around a page float:
<dl>
<dt>none
<dd>other content may not wrap around the page float
<dt>wrap
<dd>other content may wrap around the page float
</dl>
</dl>
<p>The 'intrude' value only works in combination with one of these keywords: 'left'/'right'/'top'/'bottom'/'top-corner'/'bottom-corner'.
<div class=example>
<pre class=css>
img { float: top; column-span: 2; float-wrap: wrap; width: 120%; }
</pre>
<p>In this example, the image is wider than the column and will
therefore intrude into the neighboring column. At the bottom of the
middle column is a long word that is clipped in the middle of the
column gap.
<img alt="sample rendering" src=1.png>
</div>
<h3>The 'float-offset' property</h3>
<table class=propdef>
<tr>
<td><em>Name:</em>
<td><dfn>float-offset</dfn>
<tr>
<td><em>Value:</em>
<td>&lt;length> &lt;length> ?
<tr>
<td><em>Initial:</em>
<td>0 0
<tr>
<td><em>Applies to:</em>
<td>floated elements
<tr>
<td><em>Inherited:</em>
<td>no
<tr>
<td><em>Percentages:</em>
<td>see prose
<tr>
<td><em>Media:</em>
<td>visual, paged
<tr>
<td><em>Computed&nbsp;value:</em>
<td>one or two absolute lengths
</table>
<p>This property pushes a float in opposite direction of the where
it has been floated with 'float'. If one value is specified, it is
the horizontal offset. If two values are specified, the first is the
horizontal and the second is the vertical offset. If no vertical value
has been specified, the vertical offset is set to zero.
<p>This property can only influence a float along an axis it has been floated.
<div class=example>
<pre>
img {
float: left;
float-offset: 2em 3em;
}
</pre>
<p>In this example, the image is floated to the left. Therefore, 'float-offset' may only push the element in the horizontal direction, and the vertical value is ignored.
</div>
<p>Negative values are allowed; a negative values will push the float
in the same direction as it has been floated with 'float'
<p>This property may move floats into other column than where they
naturally appear.
<div class=example>
<pre>img {
float: right;
float-offset: 5px;
}
</pre>
<img alt="sample rendering" src=14.png>
</div>
<p>Percentage values are computed according to this formula:
<pre>
(containing-block-width - float-width) * percentage
(containing-block-height - float-height) * percentage
</pre>
<div class=example>
Pull quotes are often centered in a column. In this example, the pull quote is floated to the right, and then pushed back into the center.
<img width=213 src="exclusion_wrap_side_left.png">
<pre>
.pullquote {
float: right;
float-offset: 50%; /* 50% centers the box */
}
</pre>
</div>
<p>When negative values are set on this property, the column gap is also part of the calculation:
<pre>
((containing-block-width + 2 * column-gap) - float-width) * percentage
</pre>
<div class=example>
<pre>img {
float: top right;
float-offset: -50% 3em; /* 50% centers the box */
width: 120%;
}
</pre>
<img alt="sample rendering" src=11.png>
</div>
<div class="example">
<pre>
img {
float: top right;
float-offset: -80% 2em;
width: 100%;
}
</pre>
<img alt="sample rendering" src=12.png>
</div>
<!--
<h2>Page and column floats, alternative syntax</h2>
<p>This section describes an alternative syntax for page and column floats.
<p>Four new keywords on 'float' have been added:
<dl>
<dt>left, right, top, bottom
<dd>relative to physical viewport
<dt>line-left, line-right
<dd>relative to inline axis
<dt>before, after
<dd>relative to block direction
<dt>inside, outside
<dd>as described in the previous section
<dt>footnote
<dd>as described above
<dt>columns(n)
<dd>makes the float span n columns, and sets the float context to be the multicol element
<dt>page
<dd>sets the float context to be the page
</dl>
<div class=example>
<p>Float figure to the top right corner of the multicol element, spanning two columns:
<pre>
.figure { float: top rigth columns(2); width: 100% }
</pre>
<img alt="sample rendering" src=8.png>
</div>
<div class=example>
<p>Float figure to top of the last column of the multicol element on the current page:
<pre>
.figure { float: top right columns(1) }
</pre>
<img alt="sample rendering" src=6.png>
</div>
<div class=example>
<p>Float figure to the top right of the current element, allowing other content on its side:
<pre>
.figure { float: top right; width: 60% }
</pre>
<img alt="sample rendering" src=13.png>
</div>
<div class=example>
<p>Escape the multicol element and float to the top right of the page area:
<pre>
.figure { float: top right page }
</pre>
</div>
-->
<h3>Overconstrained page floats</h3>
<p>In many cases, the specified values on these properties cannot be honored.
<div class=example>The number of columns is limited, and high values therefore cannot be honored:
<pre>
.figure { float: top; float-defer-column: 1000 }
</pre>
</div>
<div class=example>A narrow screen may only have room for one column, in which case this request cannot be honored:
<pre>
.figure { float: top; float-defer-column: -5 }
</pre>
</div>
<div class=example>In long documents, all content cannot fit on the last page, and this rule therefore cannot be honored:
<pre>
p { float: top; float-defer-page: last }
</pre>
</div>
<p>Page floats are processed in the order they appear in the source. However, the visual order of page floats may not ne the same as the source order.
<div class=example>Consider this code:
<pre>
.one { float: top; float-defer-page: last; column-span: all }
.two { float: top; clear: column }
&lt;div class=one>&lt;/div>
&lt;div class=two>&lt;/div>
</pre>
<p>In this example, the first element requests to appear on the last page, while the second element requests to appear in the natural column. If the natural column of the second element appears on a page before the last page, the second element will appear visually before the first.
</div>
<div class=example>Consider this code:
<pre>
.one { float: top; float-defer-page: last; column-span: all }
.two { float: top; clear: column }
&lt;div class=one>&lt;/div>
&lt;div class=two>&lt;/div>
</pre>
<p>If all content can fit on one page, the first page will also be the last page. The first element is processed first and is placed on top of the first page. Then the second element is processed. It reqests a clear top, somthing which is not possible on the first page. Therefore, a second page is created and the first element is moved there. Even if the first element requests to be on the last page, it will not appear there.
</div>
<p>When resolving over-constrained layouts, the order of importance for defined goals are:
<ol>
<li>honor basic multi-column layout ('columns', 'column-span: all', 'column-gap' etc)
<li>honor 'column-span: &lt;integer>'
<li>honor 'clear: top/bottom/pcolumn/page'
<li>honor 'float-defer-page'
<li>honor 'float-defer-column'
<li>honor 'float: top/bottom'
<li>display all content (as described by other CSS properties)
<li>keep the number of pages to a minimum
</ol>
<h2>Exclusions</h2>
<h3>The 'clear-side' property</h3>
<table class=propdef>
<tr>
<td><em>Name:</em>
<td><dfn>clear-side</dfn>
<tr>
<td><em>Value:</em>
<td>auto <!-- | left | right--> | both
<tr>
<td><em>Initial:</em>
<td>auto
<tr>
<td><em>Applies to:</em>
<td>floated elements
<tr>
<td><em>Inherited:</em>
<td>no
<tr>
<td><em>Percentages:</em>
<td>N/A
<tr>
<td><em>Media:</em>
<td>visual, paged
<tr>
<td><em>Computed&nbsp;value:</em>
<td>as specified
</table>
<p>This property declares if the side of a float should be cleared of
content. Values have the following meaning:
<dl>
<dt>auto
<dd>if the float is left-floated, there should be no content to the left; if the float is right-floated, there should be no content to the right
<!_-
<dt>left
<dd>there should be no content to the left of the float
<dt>right
<dd>there should be no content to the left of the float
-->
<dt>none
<dd>there may be content on either side of the float
</dl>
<!--
<h3>Pull-quotes</h3>
<div class=example>
<img width=213 src="exclusion_wrap_side_left.png">
<pre>
.pullquote {
float: right;
float-offset: 5em;
}
</pre>
<pre>
.pullquote {
float: right;