8000 csswg-drafts/css-align/Overview.html at 7eda583d836680697b1a6bca549374cf73cefdd7 · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
1898 lines (1427 loc) · 68 KB

File metadata and controls

1898 lines (1427 loc) · 68 KB
<!DOCTYPE html>
<html lang=en>
<head>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>CSS Box Alignment Module Level 3</title>
<!--
<link href="http://purl.org/dc/terms/" rel="schema.dcterms">
<link href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright" rel="dcterms.rights">
-->
<meta content="CSS Box Alignment Module Level 3" name=dcterms.title>
<meta content=text name=dcterms.type>
<meta content=2013-04-22 name=dcterms.date>
<meta content="Elika J. Etemad" name=dcterms.creator>
<meta content=W3C name=dcterms.publisher>
<meta content="http://dev.w3.org/csswg/css3-align/"
name=dcterms.identifier>
<link href="#contents" rel=contents>
<link href="#index" rel=index>
<link href="../default.css" rel=stylesheet type="text/css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<link href="http://www.w3.org/StyleSheets/TR/W3C-ED.css" rel=stylesheet
type="text/css">
<style type="text/css">
.issue th:first-child { text-align: left !important; }
[rowspan] > img { max-height: 4em; float: right; }
[rowspan] { vertical-align: middle; }
small { display: block; }
</style>
<body>
<div class=head> <!--begin-logo-->
<p><a href="http://www.w3.org/"><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a> <!--end-logo-->
<h1>CSS Box Alignment Module Level 3</h1>
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 22 April 2013</h2>
<dl>
<dt>This version:
<!--<dd><a href="http://dev.w3.org/csswg/css3-align/">http://www.w3.org/TR/2013/WD-css3-align-20130422/</a>-->
<dd>ED-css3-align-20130422
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css3-align/">http://www.w3.org/TR/css3-align/</a>
<dt>Editor's draft:
<dd><a
href="http://dev.w3.org/csswg/css3-align/">http://dev.w3.org/csswg/css3-align/</a>
<dt>Previous version:
<dd><a
href="http://www.w3.org/TR/2012/WD-css3-align-20120612/">http://www.w3.org/TR/2012/WD-css3-align-20120612/</a>
<dt>Issue Tracking:
<dd><a
href="http://www.w3.org/Style/CSS/Tracker/products/39">http://www.w3.org/Style/CSS/Tracker/products/39</a>
<dt>Feedback:
<dd><a
href="mailto:www-style@w3.org?subject=%5Bcss-align%5D%20feedback">www-style@w3.org</a>
with subject line “<kbd>[css-align] <var>… message topic
…</var></kbd>” (<a
href="http://lists.w3.org/Archives/Public/www-style/"
rel=discussion>archives</a>)
<dt>Editors:
<dd class="h-card vcard"> <a class="p-name fn u-url url"
href="http://fantasai.inkedblade.net/contact" rel=author>Elika J.
Etemad</a>, <span class="p-org org">Mozilla</span>
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2013 <a href="http://www.w3.org/"><abbr
title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a
href="http://www.csail.mit.edu/"><abbr
title="Massachusetts Institute of Technology">MIT</abbr></a>, <a
href="http://www.ercim.eu/"><abbr
title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
<a href="http://www.keio.ac.jp/">Keio</a>, <a
href="http://ev.buaa.edu.cn/">Beihang</a>), All Rights Reserved. W3C <a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a
href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a
href="http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
<!--end-copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id=abstract>Abstract</h2>
<p>This module contains the features of <a
href="http://www.w3.org/TR/CSS/">CSS</a> relating to the alignment of
boxes within their containers in the various CSS box layout models: block
layout, table layout, flex layout, and grid layout. (The alignment of text
and inline-level content is defined in <a href="#CSS3TEXT"
rel=biblioentry>[CSS3TEXT]<!--{{CSS3TEXT}}--></a> and <a href="#CSS3LINE"
rel=biblioentry>[CSS3LINE]<!--{{CSS3LINE}}--></a>.) CSS is a language for
describing the rendering of structured documents (such as HTML and XML) on
screen, on paper, in speech, etc.
<h2 class="no-num no-toc" id=status>Status of this document</h2>
<!--begin-status-->
<p>This is a public copy of the editors' draft. It is provided for
discussion only and may change at any moment. Its publication here does
not imply endorsement of its contents by W3C. Don't cite this document
other than as work in progress.
<p>The (<a
href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public
mailing list <a
href="mailto:www-style@w3.org?Subject=%5Bcss3-align%5D%20PUT%20SUBJECT%20HERE">
www-style@w3.org</a> (see <a
href="http://www.w3.org/Mail/Request">instructions</a>) is preferred for
discussion of this specification. When sending e-mail, please put the text
“css3-align” in the subject, preferably like this:
“[<!---->css3-align<!---->] <em>…summary of comment…</em>”
<p>This document was produced by the <a
href="http://www.w3.org/Style/CSS/members">CSS Working Group</a> (part of
the <a href="http://www.w3.org/Style/">Style Activity</a>).
<p>This document was produced by a group operating under the <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
2004 W3C Patent Policy</a>. W3C maintains a <a
href="http://www.w3.org/2004/01/pp-impl/32061/status"
rel=disclosure>public list of any patent disclosures</a> made in
connection with the deliverables of the group; that page also includes
instructions for disclosing a patent. An individual who has actual
knowledge of a patent which the individual believes contains <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the W3C Patent Policy</a>.</p>
<!--end-status-->
<p>The following features are at risk: …
<h2 class="no-num no-toc" id=contents> Table of contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#intro"><span class=secno>1. </span> Introduction</a>
<ul class=toc>
<li><a href="#placement"><span class=secno>1.1. </span> Module
interactions</a>
<li><a href="#values"><span class=secno>1.2. </span> Values</a>
</ul>
<li><a href="#overview"><span class=secno>2. </span> Overview of Alignment
Properties</a>
<li><a href="#alignment-values"><span class=secno>3. </span> Alignment
Values</a>
<ul class=toc>
<li><a href="#positional-values"><span class=secno>3.1. </span>
Positional Alignment: the ‘<code class=css>center</code>’, ‘<code
class=css>start</code>’, ‘<code class=css>end</code>’, ‘<code
class=css>self-start</code>’, ‘<code class=css>self-end</code>’,
‘<code class=css>flex-start</code>’, ‘<code
class=css>flex-end</code>’, ‘<code class=css>left</code>’, and
‘<code class=css>right</code>’ keywords</a>
<li><a href="#baseline"><span class=secno>3.2. </span> Baseline
Alignment: the ‘<code class=css>baseline</code>’ keyword</a>
<li><a href="#distribution-values"><span class=secno>3.3. </span>
Distributed Alignment: the ‘<code class=css>space-between</code>’,
‘<code class=css>space-around</code>’, and ‘<code
class=css>space-evenly</code>’ keywords</a>
<li><a href="#overflow-values"><span class=secno>3.4. </span> Overflow
Alignment: the ‘<code class=css>safe</code>’ and ‘<code
class=css>true</code>’ keywords</a>
</ul>
<li><a href="#content-distribution"><span class=secno>4. </span> Content
Distribution: the ‘<code class=property>justify-content</code>’ and
‘<code class=property>align-content</code>’ properties</a>
<li><a href="#self-alignment"><span class=secno>5. </span> Self-Alignment:
Aligning the Box within its Parent</a>
<ul class=toc>
<li><a href="#justify-self-property"><span class=secno>5.1. </span>
Inline/Main-Axis Alignment: the ‘<code
class=property>justify-self</code>’ property</a>
<li><a href="#align-self-property"><span class=secno>5.2. </span>
Block/Cross-Axis Alignment: the ‘<code
class=property>align-self</code>’ property</a>
</ul>
<li><a href="#default-alignment"><span class=secno>6. </span> Default
Alignment</a>
<ul class=toc>
<li><a href="#justify-items-property"><span class=secno>6.1. </span>
Inline/Main-Axis Alignment: the ‘<code
class=property>justify-items</code>’ property</a>
<li><a href="#align-items-property"><span class=secno>6.2. </span>
Block/Cross-Axis Alignment: the ‘<code
class=property>align-items</code>’ property</a>
</ul>
<li><a href="#conformance"><span class=secno>7. </span> Conformance</a>
<ul class=toc>
<li><a href="#conventions"><span class=secno>7.1. </span> Document
conventions</a>
<li><a href="#conformance-classes"><span class=secno>7.2. </span>
Conformance classes</a>
<li><a href="#partial"><span class=secno>7.3. </span> Partial
implementations</a>
<li><a href="#experimental"><span class=secno>7.4. </span> Experimental
implementations</a>
<li><a href="#testing"><span class=secno>7.5. </span> Non-experimental
implementations</a>
<li><a href="#cr-exit-criteria"><span class=secno>7.6. </span> CR exit
criteria</a>
</ul>
<li class=no-num><a href="#acknowledgments"> Acknowledgments</a>
<li class=no-num><a href="#references"> References</a>
<ul class=toc>
<li class=no-num><a href="#normative-references"> Normative
references</a>
<li class=no-num><a href="#other-references"> Other references</a>
</ul>
<li class=no-num><a href="#index"> Index</a>
<li class=no-num><a href="#property-index"> Property index</a>
</ul>
<!--end-toc-->
<h2 id=intro><span class=secno>1. </span> Introduction</h2>
<p><em>This section is not normative.</em>
<p>CSS Levels 1 and 2 allowed for the alignment of text via ‘<code
class=property>text-align</code>’ and the alignment of blocks by
balancing ‘<a href="#lsquoautorsquo1"><code class=css>auto</code></a>’
margins. However, except in table cells, vertical alignment was not
possible. As CSS3 adds further capabilities, the ability to align boxes in
various dimensions becomes more critical. This module attempts to create a
cohesive and common box alignment model to share among all of CSS.
<p class=note>The alignment of text and inline-level content is defined in
<a href="#CSS3TEXT" rel=biblioentry>[CSS3TEXT]<!--{{CSS3TEXT}}--></a> and
<a href="#CSS3LINE" rel=biblioentry>[CSS3LINE]<!--{{CSS3LINE}}--></a>.
<p>Inspiration for this document:
<ul>
<li><a
href="http://wiki.csswg.org/ideas/centering#alignment-property">summary
of a discussion for implementing &lt;CENTER&gt;</a>
<li><a
href="https://lists.w3.org/Archives/Member/w3c-css-wg/2008AprJun/0015.html">Minutes
from March 2008 F2F</a>
<li><a
href="http://lists.w3.org/Archives/Public/www-style/2012Feb/0743.html">fantasai's
attempt to merge all alignment properties</a>
</ul>
<h3 id=placement><span class=secno>1.1. </span> Module interactions</h3>
<p>This module adds some new alignment capabilities to the block layout
model described in <a href="#CSS21"
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a> chapters 9 and 10 and defines
the interaction of these properties with the alignment of table cell
content using ‘<code class=property>vertical-align</code>’, as defined
in <a href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a> chapter
17. The interaction of these properties with Grid Layout <a
href="#CSS3-GRID-LAYOUT"
rel=biblioentry>[CSS3-GRID-LAYOUT]<!--{{!CSS3-GRID-LAYOUT}}--></a> and
Flexible Box Layout <a href="#CSS3-FLEXBOX"
rel=biblioentry>[CSS3-FLEXBOX]<!--{{!CSS3-FLEXBOX}}--></a> is defined in
their respective modules.
<p>No properties in this module apply to the <code>::first-line</code> or
<code>::first-letter</code> pseudo-elements.
<h3 id=values><span class=secno>1.2. </span> Values</h3>
<p>This specification follows the <a
href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
definition conventions</a> from <a href="#CSS21"
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 <a
href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>. Other CSS
modules may expand the definitions of these value types: for example <a
href="#CSS3VAL" rel=biblioentry>[CSS3VAL]<!--{{CSS3VAL}}--></a>, when
combined with this module, adds the ‘<code class=css>initial</code>’
keyword as a possible property value.
<p>In addition to the property-specific values listed in their definitions,
all properties defined in this specification also accept the <a
href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
keyword as their property value. For readability it has not been repeated
explicitly.
<h2 id=overview><span class=secno>2. </span> Overview of Alignment
Properties</h2>
<p>The alignment properties in CSS can be described along two axes:
<ul>
<li>which dimension they apply to (inline vs. stacking), and
<li>whether they control the position of the box within its parent, or the
box's content within itself.
</ul>
<p class=note>This proposal uses the terms ‘<code
class=property>justify</code>’ and ‘<code
class=property>align</code>’ to distinguish between alignment in the
inline and stacking dimensions, respectively. The choice is somewhat
arbitrary, but having the two terms allows for a consistent naming scheme
that works across all of CSS's layout models.
<p>Th 133E e following table summarizes the proposed alignment properties and the
display types they can apply to.
<table class=data>
<colgroup span=1></colgroup>
<colgroup span=2></colgroup>
<colgroup span=1></colgroup>
<thead>
<tr>
<th>Common
<th>Axis
<th>Aligns
<th>Applies to
<tbody>
<tr>
<th>‘<a href="#justify-self"><code
class=property>justify-self</code></a>’
<td>inline
<td rowspan=2><img alt="" src=self-target.jpg> element within parent
<small>(effectively adjusts margins)</small>
<td>block-level elements and grid items
<tr>
<th>‘<a href="#align-self"><code
class=property>align-self</code></a>’
<td>stacking
<td>flex items and grid items
<tbody>
<tr>
<th>‘<a href="#justify-content"><code
class=property>justify-content</code></a>’
<td>inline
<td rowspan=2><img alt="" src=content-target.jpg>content within element
<small>(effectively adjusts padding)</small>
<td>block containers and flex containers
<tr>
<th>‘<a href="#align-content"><code
class=property>align-content</code></a>’
<td>stacking
<td>block containers and flex containers
<tbody>
<tr>
<th>‘<a href="#justify-items"><code
class=property>justify-items</code></a>’
<td>inline
<td rowspan=2><img alt="" src=child-target.jpg> items inside element
<small>(controls child items’ ‘<code class=css>align/justify-self:
auto</code>’)</small>
<td>grid containers
<tr>
<th>‘<a href="#align-items"><code
class=property>align-items</code></a>’
<td>stacking
<td>flex containers and grid containers
</table>
<p class=issue> The exact behavior of these properties on layout models
other than Flexbox is still <strong>to be determined</strong>. This is a
<strong>First Public Working Draft</strong> and is <strong>NOT
STABLE</strong>.
<p class=note> The ‘<code class=property>-items</code>’ values don't
affect the element itself. When set on a flex container or grid container,
they specify the interpretation of any ‘<code
class=css>align/justify-self: auto</code>’ used on the items in the
container element.
<p class=issue>True alignment vs. safe alignment. Maybe make safe by
default, true if ‘<a href="#lsquotruersquo"><code
class=css>true</code></a>’ is specified? Or safe/true depending on
layout model (e.g. safe for blocks, true for flexbox)? Current draft
introduces a ‘<a href="#lsquotruersquo"><code
class=css>true</code></a>’ keyword, but other options should be
considered.
<h2 id=alignment-values><span class=secno>3. </span> Alignment Values</h2>
<p>All of the alignment properties use a common set of values, defined
below.
<dl>
<dt><dfn id=alignment-subject>alignment subject</dfn>
<dd> The <a href="#alignment-subject"><i>alignment subject</i></a> is the
thing or things being aligned by the property. For ‘<a
href="#justify-self"><code class=property>justify-self</code></a>’ and
‘<a href="#align-self"><code class=property>align-self</code></a>’,
the <a href="#alignment-subject"><i>alignment subject</i></a> is the
margin box of the box the property is set on. For ‘<a
href="#justify-content"><code
class=property>justify-content</code></a>’ and ‘<a
href="#align-content"><code class=property>align-content</code></a>’,
the <a href="#alignment-subject"><i>alignment subject</i></a> is defined
by the layout mode.
<dt><dfn id=alignment-container>alignment container</dfn>
<dd> The <a href="#alignment-container"><i>alignment container</i></a> is
the rectangle that the <a href="#alignment-subject"><i>alignment
subject</i></a> is aligned within. This is defined by the layout mode,
but is usually the <a href="#alignment-subject"><i>alignment
subject</i></a>’s containing block.
</dl>
<h3 id=positional-values><span class=secno>3.1. </span> Positional
Alignment: the ‘<a href="#lsquocenterrsquo"><code
class=css>center</code></a>’, ‘<a href="#lsquostartrsquo"><code
class=css>start</code></a>’, ‘<a href="#lsquoendrsquo"><code
class=css>end</code></a>’, ‘<a href="#lsquoself-startrsquo"><code
class=css>self-start</code></a>’, ‘<a href="#lsquoself-endrsquo"><code
class=css>self-end</code></a>’, ‘<a href="#lsquoflex-startrsquo"><code
class=css>flex-start</code></a>’, ‘<a href="#lsquoflex-endrsquo"><code
class=css>flex-end</code></a>’, ‘<a href="#lsquoleftrsquo"><code
class=css>left</code></a>’, and ‘<a href="#lsquorightrsquo"><code
class=css>right</code></a>’ keywords</h3>
<p>...
<pre class=prod>
<dfn
id=ltitem-position>&lt;item-position></dfn> = center | stretch | start | end | self-start | self-end |
flex-start | flex-end | left | right;
<dfn
id=ltcontent-position>&lt;content-position></dfn> = center | start | end | flex-start | flex-end | left | right;</pre>
<dl>
<dt><dfn id=lsquocenterrsquo>‘<code class=css>center</code>’</dfn>
<dd>Centers the <a href="#alignment-subject"><i>alignment subject</i></a>
within its <a href="#alignment-container"><i>alignment container</i></a>.
<dt><dfn id=lsquostretchrsquo>‘<code class=css>stretch</code>’</dfn>
<dd>If the ‘<code class=property>width</code>’ or ‘<code
class=property>height</code>’ (as appropriate) of the <a
href="#alignment-subject"><i>alignment subject</i></a> is ‘<a
href="#lsquoautorsquo1"><code class=css>auto</code></a>’, its used
value is the length necessary to make the <a
href="#alignment-subject"><i>alignment subject</i></a>’s outer size as
close to the size of the <a href="#alignment-container"><i>alignment
container</i></a> as possible, while still respecting the constraints
imposed by ‘<code class=css>min/max-width/height</code>’. Otherwise,
this is equivalent to ‘<a href="#lsquostartrsquo"><code
class=css>start</code></a>’.
<dt><dfn id=lsquostartrsquo>‘<code class=css>start</code>’</dfn>
<dd>Aligns the <a href="#alignment-subject"><i>alignment subject</i></a>
to be flush with the <a href="#alignment-container"><i>alignment
container</i></a>’s start edge.
<dt><dfn id=lsquoendrsquo>‘<code class=css>end</code>’</dfn>
<dd>Aligns the <a href="#alignment-subject"><i>alignment subject</i></a>
to be flush with the <a href="#alignment-container"><i>alignment
container</i></a>’s end edge.
<dt><dfn id=lsquoself-startrsquo>‘<code
class=css>self-start</code>’</dfn>
<dd>Aligns the <a href="#alignment-subject"><i>alignment subject</i></a>
to be flush with the edge of the <a
href="#alignment-container"><i>alignment container</i></a> corresponding
to the <a href="#alignment-subject"><i>alignment subject</i></a>’s
start side.
<dt><dfn id=lsquoself-endrsquo>‘<code class=css>self-end</code>’</dfn>
<dd>Aligns the <a href="#alignment-subject"><i>alignment subject</i></a>
to be flush with the edge of the <a
href="#alignment-container"><i>alignment container</i></a> corresponding
to the <a href="#alignment-subject"><i>alignment subject</i></a>’s end
side.
<dt><dfn id=lsquoflex-startrsquo>‘<code
class=css>flex-start</code>’</dfn>
<dd><strong>Only used in flex layout.</strong> <a href="#CSS3-FLEXBOX"
rel=biblioentry>[CSS3-FLEXBOX]<!--{{!CSS3-FLEXBOX}}--></a> Aligns the <a
href="#alignment-subject"><i>alignment subject</i></a> to be flush with
the edge of the <a href="#alignment-container"><i>alignment
container</i></a> corresponding to the <i>flex container</i>’s
main-start or cross-start side, as appropriate. When used in layout modes
other than Flexbox, this is equivalent to ‘<a
href="#lsquostartrsquo"><code class=css>start</code></a>’.
<dt><dfn id=lsquoflex-endrsquo>‘<code class=css>flex-end</code>’</dfn>
<dd><strong>Only used in flex layout.</strong> Aligns the <a
href="#alignment-subject"><i>alignment subject</i></a> to be flush with
the edge of the <a href="#alignment-container"><i>alignment
container</i></a> corresponding to the <i>flex container</i>’s main-end
or cross-end side, as appropriate. When used in layout modes other than
Flexbox, this is equivalent to ‘<a href="#lsquostartrsquo"><code
class=css>start</code></a>’.
<dt><dfn id=lsquoleftrsquo>‘<code class=css>left</code>’</dfn>
<dd>Aligns the <a href="#alignment-subject"><i>alignment subject</i></a>
to be flush with the <a href="#alignment-container"><i>alignment
container</i></a>’s <a
href="http://www.w3.org/TR/css3-writing-modes/#line-left">line-left</a>
edge. If the property's axis is not parallel with the inline axis, this
is equivalent to ‘<a href="#lsquostartrsquo"><code
class=css>start</code></a>’.
<dt><dfn id=lsquorightrsquo>‘<code class=css>right</code>’</dfn>
<dd>Aligns the <a href="#alignment-subject"><i>alignment subject</i></a>
to be flush with the <a href="#alignment-container"><i>alignment
container</i></a>’s <a
href="http://www.w3.org/TR/css3-writing-modes/#line-right">line-right</a>
edge. If the property's axis is not parallel with the inline axis, this
is equivalent to ‘<a href="#lsquostartrsquo"><code
class=css>start</code></a>’.
</dl>
<p class=issue>Add example images.
<h3 id=baseline><span class=secno>3.2. </span> Baseline Alignment: the
‘<a href="#lsquobaselinersquo"><code class=css>baseline</code></a>’
keyword</h3>
<p>...
<dl>
<dt><dfn id=lsquobaselinersquo>‘<code class=css>baseline</code>’</dfn>
<dd>For table cells, grid items, and flex items, aligns the cell/item's
<i>first formatted line</i>&apos;s baseline, if any, with the same
baseline in other ‘<a href="#lsquobaselinersquo"><code
class=css>baseline</code></a>’-aligned cells/items in the row/column
(as appropriate for the axis). This is similar to the behavior of
‘<code class=css>vertical-align: baseline</code>’ on table cells; see
<a href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a> chapter 17
for details. If the content's position is not fully determined by
baseline alignment, the content is start-aligned insofar as possible
while preserving the baseline alignment. (Content that has no first-line
baseline is thus also start-aligned.)
</dl>
<p class=issue>Add example images.
<h3 id=distribution-values><span class=secno>3.3. </span> Distributed
Alignment: the ‘<a href="#lsquospace-betweenrsquo"><code
class=css>space-between</code></a>’, ‘<a
href="#lsquospace-aroundrsquo"><code class=css>space-around</code></a>’,
and ‘<a href="#lsquospace-evenlyrsquo"><code
class=css>space-evenly</code></a>’ keywords</h3>
<p>The distribution values are used by ‘<a href="#justify-content"><code
class=property>justify-content</code></a>’ and ‘<a
href="#align-content"><code class=property>align-content</code></a>’ to
distribute the items in the <a href="#alignment-subject"><i>alignment
subject</i></a> evenly between the start and end edges of the <a
href="#alignment-container"><i>alignment container</i></a>.
<pre class=prod>
<dfn
id=ltcontent-distribution>&lt;content-distribution></dfn> = space-between | space-around | space-evenly | stretch</pre>
<dl>
<dt><dfn id=lsquospace-betweenrsquo>‘<code
class=css>space-between</code>’</dfn>
<dd>The items are evenly distributed in the <a
href="#alignment-container"><i>alignment container</i></a>. The first
item is placed flush with the start edge of the <a
href="#alignment-container"><i>alignment container</i></a>, the last item
is placed flush with the end edge of the <a
href="#alignment-container"><i>alignment container</i></a>, and the
remaining items are distributed so that the spacing between any two
adjacent items is the same. Unless otherwise specified, this value falls
back to ‘<a href="#lsquostartrsquo"><code
class=css>start</code></a>’.
<dt><dfn id=lsquospace-aroundrsquo>‘<code
class=css>space-around</code>’</dfn>
<dd>The items are evenly distributed in the <a
href="#alignment-container"><i>alignment container</i></a>, with a
half-size space on either end. The items are distributed so that the
spacing between any two adjacent items is the same, and the spacing
before the first and after the last item is half the size of the other
spacing. Unless otherwise specified, this value falls back to ‘<a
href="#lsquocenterrsquo"><code class=css>center</code></a>’.
<dt><dfn id=lsquospace-evenlyrsquo>‘<code
class=css>space-evenly</code>’</dfn>
<dd>The items are evenly distributed in the <a
href="#alignment-container"><i>alignment container</i></a>, with a
full-size space on either end. The items are distributed so that the
spacing between any two adjacent items, before the first item, and after
the last item is the same. Unless otherwise specified, this value falls
back to ‘<a href="#lsquocenterrsquo"><code
class=css>center</code></a>’.
<dt><dfn id=lsquostretchrsquo0>‘<code class=css>stretch</code>’</dfn>
<dd>If the combined size of the items is less than the size of the <a
href="#alignment-container"><i>alignment container</i></a>, any ‘<a
href="#lsquoautorsquo1"><code class=css>auto</code></a>’-sized items
have their size increased equally so that the combined size exactly fills
the <a href="#alignment-container"><i>alignment container</i></a>.
Otherwise, or if there are no ‘<a href="#lsquoautorsquo1"><code
class=css>auto</code></a>’-sized items, this value is identical to
‘<a href="#lsquoflex-startrsquo"><code
class=css>flex-start</code></a>’. <span class=note>(For layout modes
other than flex layout, ‘<a href="#lsquoflex-startrsquo"><code
class=css>flex-start</code></a>’ is identical to ‘<a
href="#lsquostartrsquo"><code class=css>start</code></a>’.)</span>
</dl>
<p class=issue>Add example images.
<h3 id=overflow-values><span class=secno>3.4. </span> Overflow Alignment:
the ‘<a href="#lsquosafersquo"><code class=css>safe</code></a>’ and
‘<a href="#lsquotruersquo"><code class=css>true</code></a>’ keywords</h3>
<p>When the <a href="#alignment-subject"><i>alignment subject</i></a> is
larger than the <a href="#alignment-container"><i>alignment
container</i></a>, it will overflow. Some alignment modes, if honored in
this situation, may cause data loss: for example, if the contents of a
sidebar are centered, when they overflow they may send part of their boxes
past the viewport's start edge, which can't be scrolled to.
<p>To help combat this problem, an <dfn id=overflow-alignment>overflow
alignment</dfn> mode can be explicitly specified. "True" alignment honors
the specified alignment mode in overflow situations, even if it causes
data loss, while "safe" alignment changes the alignment mode in overflow
situations in an attempt to avoid data loss.
<p>If the <a href="#overflow-alignment"><i>overflow alignment</i></a> isn't
explicitly specified, the default <a
href="#overflow-alignment"><i>overflow alignment</i></a> is determined by
the layout mode. Document-centric layout modes, such as block layout,
default to "safe" <a href="#overflow-alignment"><i>overflow
alignment</i></a>, while design-centric layout modes, such as flex layout,
default to "true" <a href="#overflow-alignment"><i>overflow
alignment</i></a>.
<pre class=prod>
<dfn
id=ltoverflow-position>&lt;overflow-position></dfn> = true | safe</pre>
<dl>
<dt><dfn id=lsquosafersquo>‘<code class=css>safe</code>’</dfn>
<dd>If the size of the <a href="#alignment-subject"><i>alignment
subject</i></a> overflows the <a href="#alignment-container"><i>alignment
container</i></a>, the <a href="#alignment-subject"><i>alignment
subject</i></a> is instead aligned as if the alignment mode were ‘<a
href="#lsquostartrsquo"><code class=css>start</code></a>’.
<dt><dfn id=lsquotruersquo>‘<code class=css>true</code>’</dfn>
<dd>Regardless of the relative sizes of the <a
href="#alignment-subject"><i>alignment subject</i></a> and <a
href="#alignment-container"><i>alignment container</i></a>, the given
alignment value is honored.
</dl>
<p class=issue>Transplant example 10 from flexbox.
<h2 id=content-distribution><span class=secno>4. </span> Content
Distribution: the ‘<a href="#justify-content"><code
class=property>justify-content</code></a>’ and ‘<a
href="#align-content"><code class=property>align-content</code></a>’
properties</h2>
<p>The ‘<a href="#justify-content"><code
class=property>justify-content</code></a>’ and ‘<a
href="#align-content"><code class=property>align-content</code></a>’
properties control alignment of the box's content within the box.
<div class=figure>
<p><img
alt="Diagram showing that the alignment of the content within the element is affected."
src=content-target.jpg>
</div>
<table class=propdef>
<tbody>
<tr>
<th>Name:
<td><dfn id=justify-content>justify-content</dfn>, <dfn
id=align-content>align-content</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>auto | [ <a
href="#ltcontent-distribution"><var>&lt;content-distribution></var></a>
<a href="#ltcontent-position"><var>&lt;content-position></var></a>? |
<a href="#ltcontent-position"><var>&lt;content-position></var></a> ] &&
<a href="#ltoverflow-position"><var>&lt;overflow-position></var></a>?
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>block containers, flex containers, and grid containers
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>specified value
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td><abbr title="follows order of property value definition">per
grammar</abbr>
</table>
<p> Aligns the contents of the box as a whole along the box's
inline/row/main axis. Values other than ‘<a
href="#lsquoautorsquo1"><code class=css>auto</code></a>’ are <a
href="#alignment-values">defined above</a>.
<dl>
<dt>Block Layout:
<dd>
<p>All values other than ‘<a href="#lsquoautorsquo1"><code
class=css>auto</code></a>’ force the block container to establish a
new formatting context. ‘<a href="#lsquoautorsquo1"><code
class=css>auto</code></a>’ otherwise behaves as ‘<a
href="#lsquostartrsquo"><code class=css>start</code></a>’.
<p>The <a href="#alignment-container"><i>alignment container</i></a> is
the <i>block container</i>’s content box. The <a
href="#alignment-subject"><i>alignment subject</i></a> is the entire
contents of the block.
<p>The ‘<a href="#align-content"><code
class=property>align-content</code></a>’ property applies along the
<i>block axis</i>, but the <a
href="#ltcontent-distribution"><var>&lt;content-distribution></var></a>
values behave as their fallback values. The ‘<a
href="#justify-content"><code
class=property>justify-content</code></a>’ property does not apply to
and has no effect on block containers.
<dt>Multicol Layout:
<dd>
<p>‘<a href="#lsquoautorsquo1"><code class=css>auto</code></a>’
behaves as ‘<a href="#lsquostartrsquo"><code
class=css>start</code></a>’.
<p>The <a href="#alignment-container"><i>alignment container</i></a> is
the <i>multi-column element</i>’s content box. The <a
href="#alignment-subject"><i>alignment subject</i></a> is the column
boxes, as a unit.
<p>The ‘<a href="#align-content"><code
class=property>align-content</code></a>’ property applies along the
<i>block axis</i>, but the <a
href="#ltcontent-distribution"><var>&lt;content-distribution></var></a>
values behave as their fallback values. The ‘<a
href="#justify-content"><code
class=property>justify-content</code></a>’ property does not apply to
and has no effect on multi-column elements.
<dt>Flex Layout:
<dd>
<p>‘<a href="#lsquoautorsquo1"><code class=css>auto</code></a>’
computes to ‘<a href="#lsquostretchrsquo0"><code
class=css>stretch</code></a>’.
<p>The <a href="#alignment-container"><i>alignment container</i></a> is
the <i>flex container</i>’s content box. For ‘<a
href="#justify-content"><code
class=property>justify-content</code></a>’, the <a
href="#alignment-subject"><i>alignment subject</i></a> is the <i>flex
items</i> in each <i>flex line</i>; for ‘<a
href="#align-content"><code class=property>align-content</code></a>’,
the <a href="#alignment-subject"><i>alignment subject</i></a> is the
<i>flex lines</i>.
<p>The ‘<a href="#align-content"><code
class=property>align-content</code></a>’ property applies along the
<i>cross axis</i>. The ‘<a href="#justify-content"><code
class=property>justify-content</code></a>’ property applies along the
<i>main axis</i>, but ‘<a href="#lsquostretchrsquo0"><code
class=css>stretch</code></a>’ behaves as ‘<a
href="#lsquostartrsquo"><code class=css>start</code></a>’.
<p>See <a href="#CSS3-FLEXBOX"
rel=biblioentry>[CSS3-FLEXBOX]<!--{{!CSS3-FLEXBOX}}--></a> for details.
<dt>Grid Layout:
<dd>
<p>‘<a href="#lsquoautorsquo1"><code class=css>auto</code></a>’
computes to ‘<a href="#lsquostretchrsquo0"><code
class=css>stretch</code></a>’.
<p>The <a href="#alignment-container"><i>alignment container</i></a> is
the <i>grid container</i>’s content box. The <a
href="#alignment-subject"><i>alignment subject</i></a> is the bounds of
the <i>grid</i>. <span class=issue>Need to dfn a better term for this in
Grid.</span>
<p>The ‘<a href="#align-content"><code
class=property>align-content</code></a>’ property applies along the
<i>block (column) axis</i>. The ‘<a href="#justify-content"><code
class=property>justify-content</code></a>’ property applies along the
<i>inline (row) axis</i>. In both properties, the <a
href="#ltcontent-distribution"><var>&lt;content-distribution></var></a>
values behave as their fallback values.
</dl>
<h2 id=self-alignment><span class=secno>5. </span> Self-Alignment: Aligning
the Box within its Parent</h2>
<p> The ‘<a href="#justify-self"><code
class=property>justify-self</code></a>’ and ‘<a
href="#align-self"><code class=property>align-self</code></a>’
properties control alignment of the box within its containing block.
<div class=figure>
<p><img
alt="Diagram showing that the alignment of the element within its containing block is affected."
src=self-target.jpg>
</div>
<h3 id=justify-self-property><span class=secno>5.1. </span>
Inline/Main-Axis Alignment: the ‘<a href="#justify-self"><code
class=property>justify-self</code></a>’ property</h3>
<table class=propdef>
<tbody>
<tr>
<th>Name:
<td><dfn id=justify-self>justify-self</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>auto | baseline | [ <a
href="#ltitem-position"><var>&lt;item-position></var></a> && <a
href="#ltoverflow-position"><var>&lt;overflow-position></var></a>? ]
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>block-level boxes, absolutely-positioned boxes, and grid items
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>specified value
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td><abbr title="follows order of property value definition">per
grammar</abbr>
</table>
<p> Justifies the box within its parent along the inline/row axis: the
box's outer edges are aligned within its <a
href="#alignment-container"><i>alignment container</i></a> <a
href="#alignment-values">as described by its alignment value</a>.
<p> The ‘<a href="#lsquoautorsquo1"><code class=css>auto</code></a>’
keyword computes to ‘<a href="#lsquostretchrsquo0"><code
class=css>stretch</code></a>’ on absolutely-positioned elements, and to
the computed value of ‘<a href="#justify-items"><code
class=property>justify-items</code></a>’ on the parent (minus any ‘<a
href="#lsquolegacyrsquo"><code class=css>legacy</code></a>’ keywords) on
all other boxes.
<dl>
<dt>Block-level Boxes: