W3C

Cascading Style Sheets (CSS) Level 2

編集者草案

この日本語訳は非公式な文書です…
この文書についての詳細
索引など

要約

この仕様は、 Cascading Style Sheets level 2 (CSS 2) 改訂 2 ( CSS 2.2 )を定義する。 CSS は、[ 作者や利用者が有構造文書(例:HTML 文書や XML 応用)にスタイル(例:フォントやアキ組)を付与する ]ことを許容するスタイルシート言語である。 CSS は、[ 文書の呈示スタイルを文書の内容から分離する ]ことにより[ Web の著作, サイトの保守 ]を単純化する。 This specification defines Cascading Style Sheets level 2 (CSS 2) revision 2 (CSS 2.2). CSS is a style sheet language that allows authors and users to attach style (e.g., fonts and spacing) to structured documents (e.g., HTML documents and XML applications). By separating the presentation style of documents from the content of documents, CSS simplifies Web authoring and site maintenance.

CSS は、 媒体に特有なスタイルシートをサポートする — 作者が,自身の文書の呈示を[ 視覚ブラウザ, 聴覚機器, 印刷機, 点字装置, 携帯機器, 等々 ]にあつらえれるよう。 CSS は、[ 内容の位置決め, テーブルレイアウト, 国際化のための特能, UI に関係するいくつかのプロパティ ]もサポートする。 It supports media-specific style sheets so that authors may tailor the presentation of their documents to visual browsers, aural devices, printers, braille devices, handheld devices, etc. It also supports content positioning, table layout, features for internationalization and some properties related to user interface.

[CSS21] からの変更点は、 § 変更点を見よ。 [CSS20] からの変更点は、 [CSS21] § 変更点 を見よ。 [CSS20] を成す特能のうちいくつかは、 実装の欠如に因り, [CSS21] において CSS 2 からは除去されたことに注意 — それらの特能を参照するよう望む仕様は、 適用可能な最新な CSS モジュールを参照するべきである — [CSS] を見よ。 See Appendix C: Changes for changes from CSS 2.1, and appendix C of CSS 2.1 for changes from CSS2 (1998). Note that several CSS2 (1998) features were removed from CSS 2 in CSS 2.1 due to lack of implementations; specifications that wish to reference those features should reference the latest applicable CSS module, see [CSS].

CSS とは…

この日本語訳について

この訳は、 原文仕様の一部に限り受け持つ — 特に,現代の各種 CSS モジュールにより取って代わられた部分は、 ほとんどを省略している。 そのため、 この訳の中では定義されない用語のうち一部は, 現代の CSS による定義を参照するよう置換している。

この文書の位置付け

これは、 編集者草案の公な複製です… 【以下、この節の内容は,CSS 日本語訳 共通ページこの文書についての詳細に移譲。】

8. ボックスモデル

【 この節を成す § マージンの相殺法 以外の内容は、 今や CSS ボックスモデル [CSS-BOX-4] に包摂されるので,和訳は省略する。 】

8.3. マージンプロパティ

8.3.1. マージンの相殺法

CSS においては、 2 個以上の(互いに同胞【同じ親を共有する子】とは限らない)ボックスの いくつかのマージンが互いに連接しているときには, 単独のマージンを形成するように結合され得る。 この仕方でマージンたちを結合することを 相殺collapse ) するという†。 結合された結果のマージン【または, それを成すマージンたち】は、 相殺されたマージンcollapsed margin ) と呼ばれる。 In CSS, the adjoining margins of two or more boxes (which might or might not be siblings) can combine to form a single margin. Margins that combine this way are said to collapse, and the resulting combined margin is called a collapsed margin.

【† すなわち、 マージン区画のみ互いに重なり得る下で, 可能な限り互いの間を詰める。 】

連接している縦方向マージンは、 次に挙げる場合を除き,相殺される: Adjoining vertical margins collapse, except:

  • 根要素により生成されるボックスのマージンは、 他のマージンとは相殺されない。 Margins of the root element’s box do not collapse.
  • clearance を伴う要素の[ 上端マージン, 下端マージン ]が連接している場合、 それらのマージンは,それに連接している[ 後続する同胞のマージン ]とは相殺されるが、 その結果のマージンは,親ブロックの下端マージンとは相殺されない。 If the top and bottom margins of an element with clearance are adjoining, its margins collapse with the adjoining margins of following siblings but that resulting margin does not collapse with the bottom margin of the parent block.

横方向マージンどうしは、 決して相殺されない。 Horizontal margins never collapse.

【 CSS2 は縦書きをサポートしないので,縦方向に限定されているが、 より一般には,ブロック軸マージンに限り相殺される。 】

2つのマージンが 連接して いる( adjoining )とは、 ↓ が満たされることをいう: Two margins are adjoining if and only if:

  • 当のマージンを有する両ボックスは、 同じブロック整形文脈に関与していて,次を満たす :フロー内にあるブロックレベルである。 both belong to in-flow block-level boxes that participate in the same block formatting context
  • 両マージンを分離するような[ 行ボックスclearanceパディングボーダー ]は無い。 no line boxes, no clearance, no padding and no border separate them\

    注記: この目的においては ある種の縦幅 0 である行ボックスは、 無視されることに注意 (§ 9.4.2を見よ)。 (Note that certain zero-height line boxes (see 9.4.2) are ignored for this purpose.)

  • 両マージンとも,縦方向に隣接するボックス辺に属する — すなわち、 両者は,以下に挙げるいずれかのペアを成す: both belong to vertically-adjacent box edges, i.e. form one of the following pairs:

    • ボックスの上端マージンと, ボックスの最初の[ フロー内にある子 ]の上端マージン top margin of a box and top margin of its first in-flow child
    • ボックスの下端マージンと, ボックスの次の[ フロー内にある後続する同胞 ]の上端マージン bottom margin of box and top margin of its next in-flow following sibling
    • height の算出値が auto である ]ようなボックスの下端マージンと, ボックスの最後の[ フロー内にある子 ]の下端マージン。 bottom margin of a last in-flow child and bottom margin of its parent if the parent has auto computed height
    • ↓ を満たすボックスの[ 上端マージンと下端マージン ]:

      • 新たなブロック整形文脈を確立しない
      • min-height の算出値は 0
      • height の算出値は 0 または auto
      • フロー内にある子は無い
      top and bottom margins of a box that does not establish a new block formatting context and that has zero computed min-height, zero or auto computed height, and no in-flow children

相殺されたマージンは、 それを成す いずれかのマージン成分が,別のマージンと連接しているならば、 その別のマージンとも連接しているものと見なされる。 A collapsed margin is considered adjoining to another margin if any of its component margins is adjoining to that margin.

注記: 連接しているマージンたちは、 同胞や先祖の関係にない要素たちから生成されることもある。 Note. Adjoining margins can be generated by elements that are not related as siblings or ancestors.

注記: 上の規則は、 次を含意する: Note the above rules imply that:

  • ボックスのうち[ 浮動されるもの / 絶対的に位置されるもの / 行内ブロックであるもの ]のマージンは、 自身以外のボックス(ボックスのフロー内にある子も含む)のマージンとは相殺されない。 Margins between a floated box and any other box do not collapse (not even between a float and its in-flow children).Margins of elements that establish new block formatting contexts (such as floats and elements with overflow other than visible) do not collapse with their in-flow children.Margins of absolutely positioned boxes do not collapse (not even with their in-flow children).Margins of inline-block boxes do not collapse (not even with their in-flow children).
  • 新たなブロック整形文脈を確立する要素 (例:浮動体overflowvisible 以外をとる要素) のマージンは、 そのフロー内にある子ボックスのマージンとは相殺されない。
  • フロー内にあるブロックレベルの要素 ]の下端マージンと, 要素の次の[ フロー内にあるブロックレベルの同胞 ]の上端マージンとは、 常に相殺される — その同胞が clearance を持たない限り。 The bottom margin of an in-flow block-level element always collapses with the top margin of its next in-flow block-level sibling, unless that sibling has clearance.
  • フロー内にあるブロック要素 ]の上端マージンと, 要素の最初の[ フロー内にあるブロックレベルの子 ]の上端マージンとは、 要素は[ 上端ボーダー, 上端パディング ]を持たない, かつ 子は clearance を持たない ならば,相殺される。 The top margin of an in-flow block element collapses with its first in-flow block-level child’s top margin if the element has no top border, no top padding, and the child has no clearance.
  • フロー内にあるブロックボックスの下端マージンと, そのボックスの最後の[ フロー内にあるブロックレベルの子 ]の下端マージンは、 ↓ が満たされるならば,相殺される: The bottom margin of an in-flow block box with a height of auto and a min-height of zero collapses with its last in-flow block-level child’s bottom margin if\

    • [ ボックスの heightauto ]かつ[ ボックスの min-height は 0 ]
    • ボックスは[ 下端パディング, 下端ボーダー ]どちらも持たない the box has no bottom padding and no bottom border and\
    • 子の下端マージンと[ clearance を持つもの ]の上端マージンは、 相殺されていない。 the child’s bottom margin does not collapse with a top margin that has clearance.
  • ボックスの[ 上端マージン, 下端マージン ]は、 ↓ が満たされるならば,相殺される:

    • min-height 値は 0
    • ボックスは、次のいずれも持たない :上端ボーダー, 下端ボーダー 上端パディング, 下端パディング
    • ボックスの height は 0 または auto
    • ボックスは、 行ボックスを包含しない。
    • ボックスのフロー内にある子(もしあれば)すべてのマージンは,相殺されている。
    A box’s own margins collapse if the min-height property is zero, and it has neither top or bottom borders nor top or bottom padding, and it has a height of either 0 or auto, and it does not contain a line box, and all of its in-flow children’s margins (if any) collapse.

二つ以上のマージンが相殺されるときの結果のマージン幅は、 各相殺されたマージン幅の最大になる。 負なマージンが混じっている場合、 それらの絶対値の最大が,正なマージンの最大(正なマージンが無ければ 0 )から差し引かれる。 When two or more margins collapse, the resulting margin width is the maximum of the collapsing margins' widths. In the case of negative margins, the maximum of the absolute values of the negative adjoining margins is deducted from the maximum of the positive adjoining margins. If there are no positive margins, the maximum of the absolute values of the adjoining margins is deducted from zero.

あるボックスの[ 上端マージン, 下端マージン ]が連接している場合、 他のマージンたちが,そのようなマージンを 挟むように相殺 する( collapse through )ことも起こり得る。 この場合のボックスの位置は、[ 【そのボックスを生成した要素と】 相殺されたマージンを成す他の要素 ]との関係性に依存する: If the top and bottom margins of a box are adjoining, then it is possible for margins to collapse through it. In this case, the position of the element depends on its relationship with the other elements whose margins are being collapsed.

  • [ 要素のマージン, 要素の親の上端マージン ]が相殺されている場合、 要素のボックスの上端ボーダー辺は, 親のそれと同じ位置になるものと定義される。 If the element’s margins are collapsed with its parent’s top margin, the top border edge of the box is defined to be the same as the parent’s.
  • 他の場合、 要素の親のマージンのうち,マージン相殺の一部を成すものは、 ないか, または下端マージンのみ,のいずれかになる。 この場合の要素の上端ボーダー辺の位置は、 要素の下端ボーダーが 0 でなかったとき 【すなわち,要素の上端マージンと下端マージンとが連接してなく,相殺されなかったとき】 と同じになる。 Otherwise, either the element’s parent is not taking part in the margin collapsing, or only the parent’s bottom margin is involved. The position of the element’s top border edge is the same as it would have been if the element had a non-zero bottom border.

要素のマージンが挟むように相殺されている場合、 その位置が[ そのマージンを挟んでいる他のマージン ]を持つ要素の位置に効果を及ぼすことはないことに注意 — 要素の上端ボーダー辺の位置が要求されるのは、 これらの要素の子孫をレイアウトするときに限られる。 Note that the positions of elements that have been collapsed through have no effect on the positions of the other elements with whose margins they are being collapsed; the top border edge position is only required for laying out descendants of these elements.

9. 視覚整形モデル

9.1. 視覚整形モデル 序論

この節と次節では、 視覚整形モデル — UA が視覚的な媒体に対し,要素ツリーをどう処理するか — について述べる。 This chapter and the next describe the visual formatting model: how user agents process the document tree for visual media.

視覚整形モデルの下では、 要素ツリー内の各要素は, ボックスモデルに則って 0 個以上のボックスたちを生成する。 これらのボックスたちのレイアウトは、 次により統制される: In the visual formatting model, each element in the document tree generates zero or more boxes according to the box model. The layout of these boxes is governed by:

【† 生来な寸法( natural dimensions )は, 原文では内在的寸法( intrinsic dimensions )と称されるが、 この訳では,現代の CSS 用語に倣うよう改める (生来な[ 横幅/縦幅/縦横比 ]についても同様)。 (そのように改称されたわけは、 [CSS-SIZING-3] の用語 内在的サイズと紛らわしいことによる。) 】

この節と次節にて定義される各種プロパティは、[ 連続的媒体, ページ化媒体 ]どちらにも適用される。 しかしながら,各種マージンプロパティの意味は、 ページ化媒体に適用されるときには変わる (詳細は、 § ページモデル を見よ)。 The properties defined in this chapter and the next apply to both continuous media and paged media. However, the meanings of the margin properties vary when applied to paged media (see the page model for details).

視覚整形モデルは、 整形のすべての側面までは指定しない (例: 字詰め( letter-spacing )のアルゴリズム)。 適合 UA は、 この仕様が受け持っていない これらの整形の課題に対しては,ふるまいを違えてもよい。 The visual formatting model does not specify all aspects of formatting (e.g., it does not specify a letter-spacing algorithm). Conforming user agents may behave differently for those formatting issues not covered by this specification.

9.1.1. 表示域

連続的媒体用の UA は、 一般に,利用者が文書とやりとりするための 表示域viewport — スクリーン上のウィンドウあるいは見えている区画) を提供する。 UA は、 表示域がリサイズされたときには, 文書のレイアウトを変更してもよい (初期包含ブロックを見よ)。 User agents for continuous media generally offer users a viewport (a window or other viewing area on the screen) through which users consult a document. User agents may change the document’s layout when the viewport is resized (see the initial containing block).

UA は、 表示域が[ キャンバス内の,文書が描画される区画 ]より狭いときは,スクロール用の仕組みを提供するべきである。 When the viewport is smaller than the area of the canvas on which the document is rendered, the user agent should offer a scrolling mechanism.

表示域は,キャンバスごとに高々一つまでであるが、 UA は,複数のキャンバスに描画してもよい (すなわち、 同じ文書に対する複数のビューを同時に供してもよい)。 There is at most one viewport per canvas, but user agents may render to more than one canvas (i.e., provide different views of the same document).

9.1.2. 包含ブロック

CSS 2 においては、 多くのボックスの位置とサイズは,包含ブロック( containing block )と呼ばれる矩形なボックスの各辺を基準に計算される。 一般に、 生成されたボックスは,子孫ボックス用の包含ブロックとして動作する。 このことを、 ボックスは,(その子孫たち用の)包含ブロックを “確立する” という。 “ボックスの包含ブロック” という句は、 “ボックスが確立するそれ” ではなく, “ボックスは その包含ブロックの中に居る” ことを意味する。 In CSS 2, many box positions and sizes are calculated with respect to the edges of a rectangular box called a containing block. In general, generated boxes act as containing blocks for descendant boxes; we say that a box "establishes" the containing block for its descendants. The phrase "a box’s containing block" means "the containing block in which the box lives," not the one it generates.

各ボックスには,その包含ブロックを基準にする位置が与えられるが、 この位置は,この包含ブロックの枠内から過フローすることもある。 Each box is given a position with respect to its containing block, but it is not confined by this containing block; it may overflow.

包含ブロックの寸法を計算する方法の詳細は、 § 包含ブロックの定義 にて述べる。 The details of how a containing block’s dimensions are calculated are described in the next chapter.

9.2. ボックス生成の制御法

次の節に、 CSS 2 にて生成され得るボックスたちの各種 表示型について述べる。 ボックスの表示型は、 視覚整形モデルにおける そのふるまいに少なからず影響する。 後述の display プロパティが,ボックスの表示型を指定する。 The following sections describe the types of boxes that may be generated in CSS 2. A box’s type affects, in part, its behavior in the visual formatting model. The display property, described below, specifies a box’s type.

表示型display type )という訳語は, [CSS-DISPLAY-4] に倣ったもの — 原文では単に “型” とされている。 】

9.2.1. ブロックレベルの要素とブロックボックス

ブロックレベルの要素 とは、 視覚的にブロックとして整形されるソース文書の要素である(例: 段落など)。 要素をブロックレベルにするような display プロパティの値には,[ block, list-item, table ]がある。 Block-level elements are those elements of the source document that are formatted visually as blocks (e.g., paragraphs). The following values of the display property make an element block-level: block, list-item, and table.

ブロックレベルのボックス は、 ブロック整形文脈に関与するボックスである†。 各ブロックレベルの要素は、 主要ボックスprincipal box )と呼ばれる,ブロックレベルのボックスを生成する。 主要ボックスが、 子孫のボックスと 生成内容 を包含し、 また,位置決めスキームに関わるボックスになる。 Block-level boxes are boxes that participate in a block formatting context. Each block-level element generates a principal block-level box that contains descendant boxes and generated content and is also the box involved in any positioning scheme.

【† “関与する( participate )”: 言い換えれば、[ ボックスツリーの中で,ボックスの先祖ボックスであって, かつ整形文脈を確立しているもの ]のうち,ボックスに最も近い先祖は、[ 種別が “ブロック” である整形文脈 ]を確立していて,ボックスのレイアウトは[ その種別の整形文脈に定義される規則 ]により統制される。 】

ブロックレベルの要素には、 主要ボックスの他に追加のボックスを生成させるものもある — displaylist-item にされた要素など。 これらの追加のボックスは、 主要ボックスを基準に配置される。 Some block-level elements may generate additional boxes in addition to the principal box: list-item elements. These additional boxes are placed with respect to the principal box.

テーブルボックス, 置換要素 ]を除き,ブロックレベルのボックスは、 ブロックコンテナボックスでもある。 ブロックコンテナボックス は、 ブロックレベルのボックスのみを包含するか,または 行内整形文脈を確立する — すなわち,行内レベルのボックスのみを包含する。 ブロックコンテナボックスには、 ブロックレベルでないものもある — 置換されない[ 行内ブロック( inline-block )/ テーブル cell ( table-cell ) ]はブロックコンテナであるが、 ブロックレベルのボックスではない。 ブロックレベルのボックスであって, ブロックコンテナでもあるものは、 ブロックボックス とも呼ばれる。 Except for table boxes, which are described in a later chapter, and replaced elements, a block-level box is also a block container box. A block container box either contains only block-level boxes or establishes an inline formatting context and thus contains only inline-level boxes. Not all block container boxes are block-level boxes: non-replaced inline blocks and non-replaced table cells are block containers but not block-level boxes. Block-level boxes that are also block containers are called block boxes.

3 種の用語 “ブロックレベルのボックス”, “ブロックコンテナボックス”, “ブロックボックス” は、 多義的にならない所では,単に “ブロック” と略称されることもある。 The three terms "block-level box," "block container box," and "block box" are sometimes abbreviated as "block" where unambiguous.

整形文脈における これらのボックスの役割については、 § 9.4.X にて,俯瞰する。 】

9.2.1.1. 匿名ブロックボックス

次の様な文書において: In a document like this:

<div>
  Some text
  <p>More text
</div>

div は、 行内内容とブロック内容の両者を持つように現れる( divpdisplay はいずれも block とする)。 整形をより定義し易くするため、 "Some Text" の周りには, 匿名ブロックボックス が在るものと見做される。 【それは、ブロックコンテナになり, かつブロックレベルであるとされるので、“ブロックボックス” と称される。】 (and assuming the DIV and the P both have 'display: block'), the DIV appears to have both inline content and block content. To make it easier to define the formatting, we assume that there is an anonymous block box around "Some text".

Some text (匿名ボックス)
More text p ボックス)
上の例から生成される 3 個のボックス — 外枠の div ボックスと,その中の匿名ブロックボックス(上段)と p ボックス(下段) — を示す図式。 Diagram showing the three boxes, of which one is anonymous, for the example above.

言い換えれば、 ブロックコンテナボックスの内側にブロックレベルのボックス(上の p など)が在る場合 (上の div 用に生成されるものなど), 内側にはブロックレベルのボックスしかないよう強制される。 In other words: if a block container box (such as that generated for the DIV above) has a block-level box inside it (such as the P above), then we force it to have only block-level boxes inside it.

行内ボックス ボックスフロー内にあるブロックレベルのボックスたちが成す “連なり” を包含する場合:

  1. ボックス (および ボックス と同じ行ボックスに属する ボックス の行内先祖)は, “連なり” の周りで,分断され、
  2. 分断された前後それぞれの行ボックス群(空, すなわち 0 個の行ボックスにもなり得る)は,匿名ブロックボックスに封入される。
  3. これらの 匿名ブロックボックス, および “連なり” は,互いに同胞になる。 【 “連なり” が複数あれば、合間に生じる各行ボックス群も匿名ブロックボックスで包装される。】

ここでの “連なり” とは、[ 連続する, または[ 縮約可能空白フロー外にある要素 ]のみにより分離される ]ような,互いに同胞な 1 個以上のブロックレベルの要素を意味する。

ボックス相対位置決めによりオフセットされる場合、 その中のブロックボックスたち(匿名なそれも含む)も一緒にオフセットされる。

When an inline box contains an in-flow block-level box, the inline box (and its inline ancestors within the same line box) is broken around the block-level box (and any block-level siblings that are consecutive or separated only by collapsible whitespace and/or out-of-flow elements), splitting the inline box into two boxes (even if either side is empty), one on each side of the block-level box(es). The line boxes before the break and after the break are enclosed in anonymous block boxes, and the block-level box becomes a sibling of those anonymous boxes. When such an inline box is affected by relative positioning, any resulting translation also affects the block-level box contained in the inline box.

このモデルは、 次の例にも適用されることになる。 次の規則が: This model would apply in the following example if the following rules:

p    { display: inline }
span { display: block }

次の HTML に利用された場合: were used with this HTML document:

<body>
<p>
span の前にある匿名テキスト
<span>span の内容</span>
span の後にある匿名テキスト
</p>
</body>

p 要素は(行内レベルにされてはいるが)、 順に,[ 匿名テキスト片 C1, ブロックレベルにされた span 要素, 別の匿名テキスト片 C2 ]を包含する。 結果のボックスたちは、[ 次のものを包含している body ]を表現しているブロックボックスになる:

  1. C1 を包装する匿名ブロックボックス
  2. span によるブロックボックス
  3. C2 を包装する別の匿名ブロックボックス
The P element contains a chunk (C1) of anonymous text followed by a block-level element followed by another chunk (C2) of anonymous text. The resulting boxes would be a block box representing the BODY, containing an anonymous block box around C1, the SPAN block box, and another anonymous block box around C2.

匿名ボックスのプロパティは、 それを封入している非匿名ボックスから継承される(例: この節の最初の例では、 匿名ボックス "Some text" は,親の div から継承する)。 継承されないプロパティについては,各自の初期値にされる。 例えば、 匿名ボックスのフォントは div から継承されるが,マージンは 0 になる。 The properties of anonymous boxes are inherited from the enclosing non-anonymous box (e.g., in the example just below the subsection heading "Anonymous block boxes", the one for DIV). Non-inherited properties have their initial value. For example, the font of the anonymous box is inherited from the DIV, but the margins will be 0.

匿名ブロックボックスを生成させる要素 ]上に設定された各プロパティは、 依然として,それらのボックスと 要素の内容にも適用される。 例えば,上の例で p 要素にボーダーが設定されていたなら、 ボーダーは C1, C2 の周りにも描かれることになる (このボーダーは、[ C1C2 ]の行の[ 終端/始端 ]では開いた状態になる)。 Properties set on elements that cause anonymous block boxes to be generated still apply to the boxes and content of that element. For example, if a border had been set on the P element in the above example, the border would be drawn around C1 (open at the end of the line) and C2 (open at the start of the line).

【上の例の,利用中のブラウザによる呈示(この訳による追加):】

上の例において p にボーダー(赤線)が設定されているとき — ボーダーは,合間のブロックを飛ばして描かれるであろう。
span の前にある匿名テキスト span の内容 span の後にある匿名テキスト
一つ前の例で pdisplayblock であったなら、 ボーダーは単に p の周囲に描かれるであろう。
span の前にある匿名テキスト span の内容 span の後にある匿名テキスト
2 つ前の例から, span の前後の匿名テキストを削除したとき — それでも、 行ボックスは分割の前後に生成されるであろう。
span の内容
一つ前の例から、 更にボーダースタイルも削除したとき — 行ボックスは(少なくとも見かけ上は)生成されなくなるであろう (このふるまいの説明)。
span の内容
一つ前の例に、 p に青い外形線スタイル( outline: blue )を加えたとき — レイアウトは同じになるべきだが、 見えない行ボックスにも外形線を描く実装はあるかもしれない。
span の内容

行内ボックス ボックス が包含しているブロックのボーダーを,他の仕方で実装している UA も中にはある: 例えば、 そのような入れ子なブロックを “匿名行ボックス” の内側に包装して、 この匿名ボックスの周りに ボックス のボーダーを描くような。 [CSS1], [CSS20] は,このふるまいを定義していないので、 この別のモデルを実装するような[ [CSS1][CSS20] ] “のみの” UA であっても、 CSS 2 のこの部分には適合するものと主張できる。 このことは、 この仕様が公表された後に開発された UA には,適用されない。 Some user agents have implemented borders on inlines containing blocks in other ways, e.g., by wrapping such nested blocks inside "anonymous line boxes" and thus drawing inline borders around such boxes. As CSS1 and CSS2 (1998) did not define this behavior, CSS1-only and CSS2 (1998)-only user agents may implement this alternative model and still claim conformance to this part of CSS 2. This does not apply to UAs developed after this specification was released.

匿名ブロックボックスは、 百分率値を解決する際には,参照されずに無視される — 代わりに,先祖の非 匿名ボックスのうち,最も近いものを利用して解決される。 例えば、[ この節の最初の例の div の子である匿名ブロックボックス( "Some Text" ) ]において,百分率による縦幅を解決する際に,その包含ブロックの縦幅を知る必要があるならば、 その匿名ブロックボックスの縦幅ではなく, div により形成される包含ブロックの縦幅を利用することになる。 Anonymous block boxes are ignored when resolving percentage values that would refer to it: the closest non-anonymous ancestor box is used instead. For example, if the child of the anonymous block box inside the DIV above needs to know the height of its containing block to resolve a percentage height, then it will use the height of the containing block formed by the DIV, not of the anonymous block box.

9.2.2. 行内レベルの要素と行内ボックス

行内レベルの要素 は、 ソース文書の要素であって,その内容により,新たなブロックが形成されないものである†。 その内容 (例:段落の中で強勢されるテキスト片, 行内画像, 等々)は、 何行かに分布する。 display プロパティに対する値[ inline, inline-table, inline-block ]は、 要素を行内レベルにする。 Inline-level elements are those elements of the source document that do not form new blocks of content; the content is distributed in lines (e.g., emphasized pieces of text within a paragraph, inline images, etc.). The following values of the display property make an element inline-level: inline, inline-table, and inline-block.

行内レベルの要素は、 行内レベルのボックス を生成する。 それは、 行内整形文脈に関与するボックスである。 Inline-level elements generate inline-level boxes, which are boxes that participate in an inline formatting context.

【† 実際には,前節の例のようにブロックを生成する要素を包含することもあるので、 この定義は厳密さに欠く。 (課題 #1477) 】

行内レベルのボックスは、 次の 2 種に大別される:

行内ボックス 【 “可分な行内” 】
その内容も,ボックスが関与している行内整形文脈に関与するもの。 display 値が inline にされた置換されない要素は、 行内ボックスを生成する。
不可分な行内
行内ボックスでないもの (行内レベル置換要素が生成するボックス, 行内ブロック, 行内テーブルなど)。 その名称の由来は、 それが単独の不透明なボックスとして行内整形文脈に関与することによる。
An inline box is one that is both inline-level and whose contents participate in its containing inline formatting context. A non-replaced element with a display value of inline generates an inline box. Inline-level boxes that are not inline boxes (such as replaced inline-level elements, inline-block elements, and inline-table elements) are called atomic inline-level boxes because they participate in their inline formatting context as a single opaque box.
9.2.2.1. 匿名行内ボックス

(行内要素の内側ではなく)ブロックコンテナ要素の内側に直に包含される,どのテキストも、 匿名行内ボックスを生成するものとして扱うものとする。 Any text that is directly contained inside a block container element (not inside an inline element) must be treated as an anonymous inline element.

次の様な HTML マークアップを伴う文書において: In a document with HTML markup like this:

<p>ある<em>強勢された</em>テキスト</p>

p は、 その内側にいくつかの行内ボックスたちを伴うブロックボックスを生成する。 "強勢された" に対するボックスは,行内要素( em )により生成される行内ボックスであるが、 他のボックス( "ある" と "テキスト" )は,ブロックレベルの要素p )により生成される行内ボックスである。 後者のボックスには、 結び付けられる行内レベルの要素がないため, 匿名行内ボックス と呼ばれる。 the <p> generates a block box, with several inline boxes inside it. The box for "emphasized" is an inline box generated by an inline element (<em>), but the other boxes ("Some" and "text") are inline boxes generated by a block-level element (<p>). The latter are called anonymous inline boxes, because they do not have an associated inline-level element.

そのような匿名行内ボックスは、 その親のブロックであるボックスから継承可能なプロパティを継承する。 継承されないプロパティは、 初期値にされる。 上の例では、 匿名行内ボックスの色は p から継承されるが,背景は透明になる。 Such anonymous inline boxes inherit inheritable properties from their block parent box. Non-inherited properties have their initial value. In the example, the color of the anonymous inline boxes is inherited from the P, but the background is transparent.

空白のみからなる内容は、 white-space プロパティに則って縮約されて消える場合には,匿名行内ボックスを生成しない。 関連事項 White space content that would subsequently be collapsed away according to the white-space property does not generate any anonymous inline boxes.

この仕様では、 どの表示型の匿名ボックスを指すのか文脈から明らかな所では、 匿名行内ボックス, 匿名ブロックボックス どちらも,単に 匿名ボックス と記される。 If it is clear from the context which type of anonymous box is meant, both anonymous inline boxes and anonymous block boxes are simply called anonymous boxes in this specification.

テーブルを整形する際には、 他の表示型の匿名ボックスが導入される。 There are more types of anonymous boxes that arise when formatting tables.

9.2.3. 同行見出し( run-in )ボックス

この節は、 以前の草案と節番号を揃えるためにある。 display 用の run-in 値は、 今や CSS3 (CSS basic box model [CSS-DISPLAY-4] § 同行見出しレイアウト にて定義される。 [This section exists so that the section numbers are the same as in previous drafts. 'display: run-in' is now defined in CSS level 3 (see CSS basic box model).]

9.2.4. display プロパティ

名前 display
inline | block | list-item | inline-block | table | inline-table | <table-*> | none
初期値 inline
適用対象 すべての要素
継承 されない
百分率 受容しない
算出値 テキストを見よ
正準的順序 文法に従う

このプロパティ用の各種値の意味は: The values of this property have the following meanings:

block
この値は、 要素にブロックボックスを生成させる。 This value causes an element to generate a block box.
inline-block
この値は、 要素に行内レベルブロックコンテナを生成させる。 inline-block の内側は,ブロックボックスとして整形される一方で、 要素それ自身は不可分な行内として整形される。 This value causes an element to generate an inline-level block container. The inside of an inline-block is formatted as a block box, and the element itself is formatted as an atomic inline-level box.
inline
この値は、 要素に一つ以上の行内ボックスを生成させる。 This value causes an element to generate one or more inline boxes.
list-item
この値は、 要素に主要ブロックボックスに加えて,マーカボックスも生成させる (例:HTML の li )。 リスト, および その整形の例については、 § リスト に諮られたし。 This value causes an element (e.g., LI in HTML) to generate a principal block box and a marker box. For information about lists and examples of list formatting, please consult the section on lists.
none
この値は、 要素が整形構造に現れないようにする (すなわち,視覚媒体においては、 要素は,ボックスを生成せず, レイアウトに効果を及ぼすこともなくなる)。 要素のどの子孫も,ボックスを生成しなくなり、 要素とその内容は,整形構造から全面的に除去される。 子孫に display プロパティを設定しても, このふるまいが上書きされることはない。 This value causes an element to not appear in the formatting structure (i.e., in visual media the element generates no boxes and has no effect on layout). Descendant elements do not generate any boxes either; the element and its content are removed from the formatting structure entirely. This behavior cannot be overridden by setting the display property on the descendants.
none は、 不可視なボックスを作成するものではないことに注意。 それは、 ボックスを まったく作成させなくする。 CSS には、 要素が[ 整形に影響しつつ,それ自身は可視でない【すなわち,透明な】ボックス ]を整形構造内に生成する仕組みもある。 詳細は、 § 可視性に諮られたし。 Please note that a display of none does not create an invisible box; it creates no box at all. CSS includes mechanisms that enable an element to generate boxes in the formatting structure that affect formatting but are not visible themselves. Please consult the section on visibility for details.
table
inline-table
<table-*>
これらの値は、 要素を table 要素の様にふるまわせる (§ テーブル に述べられる制約の対象になる)。 These values cause an element to behave like a table element (subject to restrictions described in the chapter on tables).

ここで:

<table-*>
	= table-row-group
	| table-header-group
	| table-footer-group
	| table-row
	| table-column-group
	| table-column
	| table-cell
	| table-caption

これらの値の意味は、 § テーブルモデルにて定義される。

【 この <table-*> は、 他から簡潔に参照できるよう,この訳に導入した非公式な値型である (これらの値は、 テーブル整形文脈に関与するボックスを生成させる)。 】

算出値は、 指定値と同じになる。 ただし,[ 有位置な要素, 浮動要素, 根要素 ]に対する場合は除く — § display, position, float の関係性 を見よ。 The computed value is the same as the specified value, except for positioned and floating elements (see Relationships between display, position, and float) and for the root element. For the root element, the computed value is changed as described in the section on the relationships between display, position, and float.

display初期値inline とされているが、 多くの要素では,この値は[ UA の既定のスタイルシートによる規則で上書きされ得る ]ことに注意。 [HTML401] 用のスタイルシートの見本を見よ†。 Note that although the initial value of display is inline, rules in the user agent’s default style sheet may override this value. See the sample style sheet for HTML 4 in the appendix.

【† 現代の HTML ( [HTML] )における UA スタイルシートは、 その § 具現化 に定義される。 】

ここに display プロパティの例をいくつか示す: Here are some examples of the display property:

p   { display: block }
em  { display: inline }
li  { display: list-item } 
img { display: none }      /* 
画像は表示させない
Do not display images */

9.3. 位置決めスキーム

CSS 2 においては、 ボックスは,次の3種の 位置決めスキーム に則ってレイアウトし得る: In CSS 2, a box may be laid out according to three positioning schemes:

通常フロー
CSS 2 における通常フローには、 次に挙げるものが含まれる :ブロックレベルのボックスブロック整形, 行内レベルのボックス行内整形, これらのボックスの相対位置決め Normal flow. In CSS 2, normal flow includes block formatting of block-level boxes, inline formatting of inline-level boxes, and relative positioning of block-level and inline-level boxes.
浮動体

浮動モデルにおいては、 ボックスは:

  1. 先ず,通常フローに則ってレイアウトされてから†
  2. そのフローから外され、 可能な限り,[ 左方, 右方 ]いずれかへ寄せられる††。
  3. しかる後、 周りの内容は,浮動体の脇にフローし得るようになる†††。

【† すなわち、 現在の行を決定する。 】【†† 現在の行の[ 左端/右端 ]へ寄せられる。 】【††† 現在の行 以降に生成される行ボックスは、 当の浮動体の[ 右/左 ]に配置される。 】

Floats. In the float model, a box is first laid out according to the normal flow, then taken out of the flow and shifted to the left or right as far as possible. Content may flow along the side of a float.
絶対位置決め
絶対位置決めモデルにおいては、 ボックスは,通常フローからまるごと除去された上で (後続の内容はボックスが元から無かったかのようにレイアウトされる)、 包含ブロックを基準に位置があてがわれる。 Absolute positioning. In the absolute positioning model, a box is removed from the normal flow entirely (it has no impact on later siblings) and assigned a position with respect to a containing block.
【 CSS 2 における絶対位置決めに関する内容は、 今や [CSS-POSITION-3] にて定義されるので, この訳では(一部を除き)省略する。 】

[ 要素/ボックス ]のうち,次に挙げるものは フロー外 にあると呼ばれ,他のものは フロー内 にあると呼ばれる :浮動体, 絶対的に位置された要素, 根要素 An element is called out of flow if it is floated, absolutely positioned, or is the root element. An element is called in-flow if it is not out-of-flow.\

フロー とは、[ フロー外にある,ある要素を根とする下位ツリー ]から,その中の[ フロー外にある要素を根とする下位ツリー ]すべてを除外した部分である。 The flow of an element A is the set consisting of A and all in-flow elements whose nearest out-of-flow ancestor is A.

注記: CSS 2 の位置決めスキームは、 マークアップによる技巧(例:不可視な画像)を要することなく,レイアウト効果を得られるようにして、 作者が,よりアクセス可能な文書を書き易くするためにある。 Note. CSS 2’s positioning schemes help authors make their documents more accessible by allowing them to avoid mark-up tricks (e.g., invisible images) used for layout effects.

9.3.1. 位置決めスキームの選択: position プロパティ

【 この節の内容は、 今や [CSS-POSITION-3] § 位置決めスキームの選択 にて定義されるので,和訳は省略する。 】

9.3.2. ボックスのオフセット: top, right, bottom, left

【 この節の内容は、 今や [CSS-POSITION-3] § ボックスインセット にて定義されるので,和訳は省略する。 】

9.4. 通常フロー

通常フロー( normal flow )におけるボックスは、 ブロック, 行内いずれかの 整形文脈formatting context )に所属する【関与する】 — が、 これら 2 つに同時に所属することはない。 ブロックレベルのボックスは、 ブロック整形文脈に関与する。 行内レベルのボックスは、 行内整形文脈に関与する。 Boxes in the normal flow belong to a formatting context, which may be block or inline, but not both simultaneously. Block-level boxes participate in a block formatting context. Inline-level boxes participate in an inline formatting context.

9.4.X. 【ブロック整形文脈における各種ボックスの位置付け】

【 この節は、 訳者による注釈である。

この節では、 この仕様が定義する各種ボックスの,整形文脈における位置付けについての( CSS3 も視野に入れた)説明を試みる (この節は、 何かを定義するものではない)。 尚、 ここでは主要ボックスでないボックスは脇に置く。

視覚的なレイアウトは、 ボックスたちが成すツリー構造に基いて行われる。 これは、 ボックスツリー, あるいは描画ツリーとも呼ばれている (これは,概ね要素ツリーの構造を反映するが、 文書ツリーの一部は,ボックスツリーの中では別の場所に組み替えられることもある — 絶対的に位置された要素など)。 整形文脈は、 このボックスツリーの中のある下位ツリーを表現する。 上述の様に,整形文脈にはいくつかの種別があり、 ある整形文脈に関与するボックスのレイアウトは,その種別に定義される規則により統制される。

整形文脈の下位ツリーの中で,新たな整形文脈を確立するものは、 親の整形文脈の視点からは,末端の( “不透明な” )ボックスになる。 すなわち、 子孫の整形文脈に関与する内容のレイアウトには,親の整形文脈による統制は及ばない — 及ぶのは、 子整形文脈の根である末端ボックスのサイズ/位置に限られる。 一般に、 CSS に規定されるレイアウト特能のほとんどは,整形文脈を超えて影響しあうことはない (浮動体は、 ブロック整形文脈と行内整形文脈との間で影響しあう点で特別だが)。

この仕様が定義するブロック整形文脈を成す下位ツリーにおいては:

行内整形文脈は、 親の整形文脈がブロック整形文脈でないならば,暗黙的にブロック整形文脈も成すと見なされる点で特別な地位にある(すなわち,このブロック整形文脈の根自身が末端の行内整形文脈を確立する)。 言い換えれば、 “ブロックレベル”/“行内レベル” の区別が意味を成すのは,ブロック整形文脈の中に限られる — 他の種別の整形文脈の中の行内レベルのボックスは、 常にブロック整形文脈の中に包装されることになるので(ブロック整形文脈, 行内整形文脈をひっくるめたものは、 フローレイアウトとも呼ばれている)。 “ブロックコンテナ” という用語は、 ブロック整形文脈でない整形文脈の中で利用されることもある — その場合、 ブロックコンテナ自身がブロック/行内整形文脈を確立していることを含意する。 また,ブロック/行内整形文脈でない整形文脈においては、 通例,ボックスは浮動されないことになる( float を非 none に設定しても効果はない) — その文脈におけるふるまいが新たに定義されない限り。 したがって、 浮動という用語は,ブロック整形文脈の存在を含意することになる。

9.4.1. ブロック整形文脈

次のものは、 その内容に対し,新たなブロック整形文脈を確立する:

Floats, absolutely positioned elements, block containers (such as inline-blocks, table-cells, and table-captions) that are not block boxes, and block boxes with overflow other than visible (except when that value has been propagated to the viewport) establish new block formatting contexts for their contents.

ブロック整形文脈の下では、 各ボックスは,包含ブロックの上端から, 縦方向に, 順々に,レイアウトされる。 2 個の同胞ボックスの縦方向の間隔は、 それらの margin プロパティにより決定される。 同じブロック整形文脈に関与する,隣り合うブロックレベルのボックスでは、 その合間の縦方向マージンは,相殺される。 In a block formatting context, boxes are laid out one after the other, vertically, beginning at the top of a containing block. The vertical distance between two sibling boxes is determined by the margin properties. Vertical margins between adjacent block-level boxes in a block formatting context collapse.

ブロック整形文脈の下では、 各ボックスの左端外縁辺は, 包含ブロックの左端辺に接する(右横書き整形に対しては右端辺どうしが接する)。 このことは、 浮動体が存在していても成り立つ(ボックス内の 行ボックス は、 浮動体に因り縮短され得るが) — そのボックスが,新たなブロック整形文脈を確立するのでない限り (この場合、 ボックス自身は,浮動体に因りより幅狭になり得る)。 In a block formatting context, each box’s left outer edge touches the left edge of the containing block (for right-to-left formatting, right edges touch). This is true even in the presence of floats (although a box’s line boxes may shrink due to the floats), unless the box establishes a new block formatting context (in which case the box itself may become narrower due to the floats).

ページ化媒体におけるページ分断については、 § 許容されるページ分断に諮られたし。 For information about page breaks in paged media, please consult the section on allowed page breaks.

9.4.2. 行内整形文脈

行内整形文脈の下では、 ボックスたちは,その包含ブロックの上端から, 横方向に,順々にレイアウトされていく。 これらのボックスの合間の横方向[ マージン/ボーダー/パディング ]は、 尊重される†。 一連のボックスが縦方向に整列される仕方は、 様々になり得る: それらの下端/上端が,互いに整列されることもあれば、 それらのテキストの基底線が 互いに整列されることもある。 ある一つの行を形成するボックスたちを包含する矩形な区画は、 行ボックス と呼ばれる。 In an inline formatting context, boxes are laid out horizontally, one after the other, beginning at the top of a containing block. Horizontal margins, borders, and padding are respected between these boxes. The boxes may be aligned vertically in different ways: their bottoms or tops may be aligned, or the baselines of text within them may be aligned. The rectangular area that contains the boxes that form a line is called a line box.

【† 行内レベルの置換されない要素に対しては、 縦方向のマージンによる効果はない。 また,[ ボーダー/パディング ]は、 縦方向でも効果はあるが,行ボックスの縦幅には影響しない(下に例を示す)。 】

行ボックスの横幅は、 その包含ブロックと, 浮動体の有無により決定される。 行ボックスの縦幅は、 § 行高の計算 に与える規則から決定される。 The width of a line box is determined by a containing block and the presence of floats. The height of a line box is determined by the rules given in the section on line height calculations.

行ボックスの高さは、 常に,それを形成しているすべてのボックスを包含するに十分な高さにされる。 しかしながら,この高さは、 それらのボックスの高さの最大よりも高くなる場合もある (例えば、 ボックスたちが互いの基底線が揃うように整列されている場合)。 ボックス B の縦幅が行ボックスより狭い場合の,その行ボックスの中での B の縦方向の整列は、 vertical-align プロパティにより決定される。 A line box is always tall enough for all of the boxes it contains. However, it may be taller than the tallest box it contains (if, for example, boxes are aligned so that baselines line up). When the height of a box B is less than the height of the line box containing it, the vertical alignment of B within the line box is determined by the vertical-align property.\

行内レベルのボックスたちが単独の行ボックスの中に横方向に収まり切らない場合、 収まり切らない部分は,次の行ボックスに折り返され 【これは、 1 個の行内レベルのボックスを複数個の行ボックスに分断し得る】 、 縦方向に堆積されていく。 したがって、 段落は,縦方向に堆積する行ボックスたちからなる。 行ボックスたちが堆積されるときは、 (他から指定されない限り)縦方向に離されることなく,また 重なり合うことも決してない。 When several inline-level boxes cannot fit horizontally within a single line box, they are distributed among two or more vertically-stacked line boxes. Thus, a paragraph is a vertical stack of line boxes. Line boxes are stacked with no vertical separation (except as specified elsewhere) and they never overlap.

一般に、 行ボックスの[ 左端辺/右端辺 ]は,その包含ブロックの[ 左端辺/右端辺 ]に接する。 しかしながら、 包含ブロックの辺と行ボックス辺の合間に,浮動ボックスが来ることもある。 したがって、 同じ行内整形文脈 内の行ボックスたちの横幅は,一般的には同じ(包含ブロックの横幅)になるが、 横方向に可用な空間が浮動体に因り抑制される場合には,変わり得ることになる。 また、 一般に,同じ行内整形文脈に関与する各行ボックスの縦幅も,まちまちになり得る(例:背が高い画像を包含する行と, テキストのみを包含する行など)。 In general, the left edge of a line box touches the left edge of its containing block and the right edge touches the right edge of its containing block. However, floating boxes may come between the containing block edge and the line box edge. Thus, although line boxes in the same inline formatting context generally have the same width (that of the containing block), they may vary in width if available horizontal space is reduced due to floats. Line boxes in the same inline formatting context generally vary in height (e.g., one line might contain a tall image while the others contain only text).

同じ行ボックス上にある一連の行内レベルのボックスの横幅の合計が,その行ボックスの横幅より狭い場合、 その行ボックスにおける,それらの横方向の分布は、 text-align プロパティにより決定される。 そのプロパティの値が justify 【 “両端揃え” 】 ならば、 UA は,行内ボックス (ただし,[ inline-table, inline-block ]ボックスは除く) 内のスペースや単語を伸張してもよい。 When the total width of the inline-level boxes on a line is less than the width of the line box containing them, their horizontal distribution within the line box is determined by the text-align property. If that property has the value justify, the user agent may stretch spaces and words in inline boxes (but not inline-table and inline-block boxes) as well.

行ボックスの横幅を超過するような行内ボックスは、 複数の行ボックスにわたるように,いくつかのボックスに分割される。 分割できない行内ボックスは、 行ボックスを過フローする(例: 単独の文字からなる行内ボックス / 言語に特有な単語分断規則から 行内ボックスの中での分断【 “改行” 】が許容されていない / 行内ボックスに対する white-space 値が nowrap または pre にされている)。 When an inline box exceeds the width of a line box, it is split into several boxes and these boxes are distributed across several line boxes. If an inline box cannot be split (e.g., if the inline box contains a single character, or language specific word breaking rules disallow a break within the inline box, or if the inline box is affected by a white-space value of nowrap or pre), then the inline box overflows the line box.

行内ボックスが分割されるとき、 どの分割の切り口の所でも,[ マージン/ボーダー/パディング ]による視覚的な効果はない。 When an inline box is split, margins, borders, and padding have no visual effect where the split occurs (or at any split, when there are several).

行内ボックスは、 双方向テキスト処理に因り, 同じ行ボックスの中であっても,複数のボックスに分割されることもある。 Inline boxes may also be split into several boxes within the same line box due to bidirectional text processing.

行ボックスは、 行内整形文脈の中で,行内レベルの内容を保持する必要に応じて作成される。 次のいずれも包含しないような行ボックスは…:

…は:

  • その内側にある要素†††の位置を決定する目的††††においては、 縦幅 0 の行ボックスとして扱うものとする。
  • 他の目的においては、 存在しないものとして扱うものとする。
Line boxes are created as needed to hold inline-level content within an inline formatting context. Line boxes that contain no text, no preserved white space, no inline elements with non-zero margins, padding, or borders, and no other in-flow content (such as images, inline blocks or inline tables), and do not end with a preserved newline must be treated as zero-height line boxes for the purposes of determining the positions of any elements inside of them, and must be treated as not existing for any other purpose.

【† この “保全空白” には,改行文字も含まれる。 】【†† この 0 は、 横方向マージン用の auto 値も含む(行内要素に対しては,その使用値は 0 になるので)。 また、 縦方向の[ マージン, パディング, ボーダー ]は何であれ,上の条件に影響しない (それは、 行ボックスの縦幅に影響しないので)。 】【††† その行ボックスを生成させた要素の,子孫が生成するボックス。 】【†††† 例えば、 浮動体現在の行の位置。 】

行内ボックスの構築例をここに示す。 ( HTML ブロックレベルの要素 p で作成された)次の段落は、 合間に[ em, strong ]要素が挟まれた,匿名テキストを包含している: Here is an example of inline box construction. The following paragraph (created by the HTML block-level element P) contains anonymous text interspersed with the elements EM and STRONG:

<p>いくつかの<em>強勢された単語</em>が,
<strong>この文の中</strong>に現れています。</p>
<p>Several <EM>emphasized words</EM> appear
<strong>in this</strong> sentence, dear.</p>

p 要素は、 ブロックボックスを生成する。 それは、 5 個の行内ボックスを包含し,うち 3 つは匿名である: The P element generates a block box that contains five inline boxes, three of which are anonymous:

  • 匿名: "いくつかの"
  • em: "強勢された単語"
  • 匿名: "が,"
  • strong: "この文の中"
  • 匿名: "に現れています。"
Anonymous: "Several" EM: "emphasized words" Anonymous: "appear" STRONG: "in this" Anonymous: "sentence, dear."

UA は、 段落を整形するときに,これら 5 ボックスをいくつかの行ボックスの中へフローする。 この例では、 p 要素により生成されるボックスが、 これらの行ボックス用に包含ブロックを確立する。 この包含ブロックが,すべての行内ボックスに足るほど幅広であれば、 単独の行ボックスに収まることになる: To format the paragraph, the user agent flows the five boxes into line boxes. In this example, the box generated for the P element establishes the containing block for the line boxes. If the containing block is sufficiently wide, all the inline boxes will fit into a single line box:

いくつかの強勢された単語が,この文の中に現れています。
Several emphasized words appear in this sentence, dear.

そうでなければ、 一部の行内ボックスが分割され、 いくつかの行ボックスにまたがることになる。 段落は、 例えば次のように分割される: If not, the inline boxes will be split up and distributed across several line boxes. The previous paragraph might be split as follows:

いくつかの強勢された単語が,
この文の中に現れています。
Several emphasized words appear
in this sentence, dear.

あるいは次の様に: or like this:

いくつかの強勢された
単語が,この文の中
に現れています。
Several emphasized  
words appear in this 
sentence, dear.

前の例では、 em ボックスは, 2 個の em ボックスたちに分割された (以下 前半, 後半 と記す)。 このボックス用の[ マージン, ボーダー, パディング, テキスト装飾 ]は、[ 前半 の終端/ 後半 の始端 ]に対しては可視効果を持たない。 In the previous example, the EM box was split into two EM boxes (call them "split1" and "split2"). Margins, borders, padding, or text decorations have no visible effect after split1 or before split2.

上の例の em 要素に、 次のスタイルが適用されたとする: Consider the following example:

em {
  padding: 2px;
  margin: 1em;
  border: medium dashed;
  line-height: 2.4em;
  background: yellow;
  color: green;
}

p の横幅に依存して、 ボックスたちは,例えば次のように分布する: Depending on the width of the P, the boxes may be distributed as follows:

いくつかの強勢された単語が,この文の中に現れています。
段落の内縁横幅
 
マージン, ボーダー, パディングの表示に対する,行分断の効果を示す図(利用中のブラウザによる呈示)。 Image illustrating the effect of line breaking on the display of margins, borders, and padding.
  • "強勢された単語" は、 2 個のボックス[ 前半, 後半 ]に分断され, 後半 は次の行に折り返されている。
  • 前半 を含む行ボックス/ 後半 を含む行ボックス ]の縦幅は、 em ボックスによる縦幅( line-height2.4em になる(図では,ちょうど 前半 のボーダーと 後半 のボーダーの下端の間隔に等しくなる)。
  • マージンは,[ 前半 の前 / 後半 の後 ]に挿入される。 The margin is inserted before "emphasized" and after "words".
  • パディングは、 前半 の[ 前, 上, 下 ]および 後半 の[ 後, 上, 下 ]に挿入される。 いずれにせよ、 点線( dashed )のボーダーは,挙げられた 3 つの側に描画される。 The padding is inserted before, above, and below "emphasized" and after, above, and below "words". A dashed border is rendered on three sides in each case.
  • 可分な行内に対しては、 縦方向[ マージン/ボーダー/パディング ]は,行ボックスの縦幅に影響しない(次の図)。 】
前に現れる内容は、 後続のテキストの背景とボーダーで覆われるかもしれない。
いくつかの強勢された単語が,この文の中に現れています。
上の例から,縦方向についてのみ[ マージン, ボーダー, パディング ]を増やしたときの,利用中のブラウザによる呈示。

9.4.3. 相対位置決め

【 この節の内容は、 今や [CSS-POSITION-3] § 相対位置決め にて定義されるので,和訳は省略する。 】

9.5. 浮動体

浮動体float — “浮動された( floated )” / “浮動( floating )” ボックスとも称される) は、 現在の行において,[ 左端, または右端 ]へ寄せられるボックスである。 浮動体の最も興味を引く特性は、 その周りの内容が,浮動体の脇に沿ってフローし得るようになることである (また、 clear プロパティにより,それを禁制することもできる)。 周りの内容は、 左方へ浮動されたボックスに対しては,その右脇から下へフローし、 右方へ浮動されたボックスに対しては,左脇から下へフローする。 以下は、 浮動体の位置決めと内容フローの序論である — 浮動体のふるまいを統制する正確な規則は、 float プロパティの記述にて与えられる。 A float is a box that is shifted to the left or right on the current line. The most interesting characteristic of a float (or "floated" or "floating" box) is that content may flow along its side (or be prohibited from doing so by the clear property). Content flows down the right side of a left-floated box and down the left side of a right-floated box. The following is an introduction to float positioning and content flow; the exact rules governing float behavior are given in the description of the float property.

現在の行 とは、 仮に,当の浮動体が “無限小な文字” — 少なくとも何らかの行ボックスを生成させるような,空な行内内容 — で代用されたとき、 それが配置されることになる行ボックスを意味する(場合によっては縦幅 0 にもなる) 。 ここでの “周りの内容” は、 現在の行, または それ以降の行ボックスに配置される内容を指す。

【 この定義は、 原文には明示的に述べられていない,この訳による補完 — このように定義されると解釈すれば、 以下の記述も筋が通る。 】

ボックス A がボックス B先行する とは、[ AB は同じブロック整形文脈に関与している ], かつ[ A を生成している要素は B を生成している要素より,ソース文書内で先に現れている ]ことを意味する。

【 この定義は、 他所を簡潔に述べるための,この訳による追加 (この節の中でしか利用されない)。 】

浮動されたボックスは、 その外縁辺が[ 包含ブロックの辺, または[ そのボックスに先行する別の浮動ボックスがあるならば,その外縁辺 ]]に接するまで、 左方へまたは右方へ寄せられる。 浮動されるボックスの上端 外縁辺は、 現在の行の上端に整列される。 A floated box is shifted to the left or right until its outer edge touches the containing block edge or the outer edge of another float. If there is a line box, the outer top of the floated box is aligned with the top of the current line box.

浮動体の脇にフローされる内容に対し,横方向の部屋が十分でない場合、 内容は[ 何らかの内容を収められるようになるか, または 浮動体を過ぎる所 ]まで,下方へずれ込む。 If there is not enough horizontal room for the float, it is shifted downward until either it fits or there are no more floats present.

浮動体はフロー内にないので、 浮動ボックスの 前/後 に作成される,有位置でないブロックボックスは、 浮動体が存在しなかったかのように縦方向にフローする†。 しかしながら、[ 浮動体の側方に重なり合う,現在の行 以降の行ボックス ]は、 浮動体のマージンボックスが占める部屋に必要とされるだけ短縮される。 Since a float is not in the flow, non-positioned block boxes created before and after the float box flow vertically as if the float did not exist. However, the current and subsequent line boxes created next to the float are shortened as necessary to make room for the margin box of the float.

【† すなわち、 浮動体に後続するブロックボックスの位置とサイズ自体は,浮動体が無かったかのように決定され、 浮動体は,ブロックボックスの中に入り込むように配置され、 ブロックボックスの行内内容は,浮動体の脇にフローする。 次の例の様に: 】

【 この例は,この訳による追加。 】

<div style="border:solid medium;">
  <mark style="float:left;">左へ浮動する内容</mark>
  <div style="border:solid thin; margin: 0.5em;">
    浮動体に後続するブロックボックス内の,行内内容
  </div>
</div>
左へ浮動する内容
浮動体に後続するブロックボックス内の,行内内容
利用中のブラウザによる,上の HTML の実際の呈示。

外縁な div の内縁辺(この例では図を囲っている矩形の内縁)が、 当のブロックボックス用の包含ブロックになる。 ブロックボックスのボーダー(図の内側にある矩形)は、 浮動体の有無に関わらず,包含ブロックの横幅のほとんど(マージンを除いた部分)を占めることになる。 現在の行は、 ブロックボックスの上端外縁辺(包含ブロックの上端)に概念的に存在する,縦幅 0 の行ボックスと見なされる。

浮動体の 側方 とは、 浮動体の上端マージン辺から下端マージン辺まで(両端は含まない)を占める,横幅無限な区画である。 A line box is next to a float when there exists a vertical position that satisfies all of these four conditions: (a) at or below the top of the line box, (b) at or above the bottom of the line box, (c) below the top margin edge of the float, and (d) above the bottom margin edge of the float.

【 この訳では、 原文による “側方” ( “a shortened line box is next to a float” ) の定義を 行ボックス以外の対象にも転用できるよう一般化した上で, この用語を利用する他の定義も 等価な言い回しに変換している。 】

注記: 外縁縦幅が 0 以下の浮動体に対しては、 その側方は空になるので,行ボックスは短縮されないことになる。 Note: this means that floats with zero outer height or negative outer height do not shorten line boxes.

行ボックスが短縮されるとき,その中にフローされる内容を包含するには短か過ぎる場合、 行ボックスは,[ 何らかの内容を収められるようになるか, または 浮動体の側方を過ぎる所 ]まで下方へずれ込む(それに伴い,その横幅も算出し直される)。 そうでなければ、 浮動ボックスが浮動されないとするとき,現在の行にフローされることになる内容は、 書字方向( direction )に関わらず,ボックスが浮動する方向の反対側にフローし直される。 If a shortened line box is too small to contain any content, then the line box is shifted downward (and its width recomputed) until either some content fits or there are no more floats present. Any content in the current line before a floated box is reflowed in the same line on the other side of the float. In other words, if inline-level boxes are placed on the line before a left float is encountered that fits in the remaining line box space, the left float is placed on that line, aligned with the top of the line box, and then the inline-level boxes already on the line are moved accordingly to the right of the float (the right being the other side of the left float) and vice versa for rtl and right floats.

次に挙げる要素のボーダーボックスは、 要素自身と同じブロック整形文脈に関与する どの浮動体のマージンボックスとも重なり合ってはならない:

実装は、 これらの要素をそのように配置する際には,必要に応じて 次を行うべきである:

  • 要素を,それに先行するどの浮動体よりも下に配置する。
  • ただし、 空間が足りるなら、 要素を それらの浮動体の隣に配置してもよい — その際には要素のボーダーボックスを § 10.3.3 に定義されるものより幅狭にしてもよい。 【浮動体が要素の clear 対象である場合、この選択肢はない。】

UA が要素をいつ浮動体の側方に置くか, あるいは 要素が どの程度 より幅狭になれるかについては、 CSS 2 では定義されない。

The border box of a table, a block-level replaced element, or an element in the normal flow that establishes a new block formatting context (such as an element with overflow other than visible) must not overlap the margin box of any floats in the same block formatting context as the element itself. If necessary, implementations should clear the said element by placing it below any preceding floats, but may place it adjacent to such floats if there is sufficient space. They may even make the border box of said element narrower than defined by section 10.3.3. CSS 2 does not define when a UA may put said element next to the float or by how much said element may become narrower.

次の文書断片において、 包含ブロックは,その内容を浮動体の側方に包含するには幅狭過ぎるので、 内容は浮動体の下に移動される。 Example. In the following document fragment, the containing block is too narrow to contain the content next to the float, so the content gets moved to below the floats where it is aligned in the line box according to the text-align property.

p { width: 10em; border: solid; }
mark { float: left; display: block; width: 5em; height: 5em; border: dashed; }
...
<p>
  <mark>浮動体</mark>
  Supercalifragilisticexpialidocious
</p>

この断片は、 次の様になるであろう: This fragment might look like this:

浮動体 Supercalifragilisticexpialidocious
分断できない内容片が,浮動体の側方に収まり切らないとき、 その下へフローし直される効果を示す図。 Image illustrating the effect of an unbreakable piece of content being reflowed to just after a float which left insufficient room next to it for the content to fit.

【 この例は,この訳による追加。 】

<div style="border:solid; width:20em;">
  浮動体の現在の行に配置される行内内容は、浮動する方向
  <mark style="float:left;">(左浮動体)</mark>
  の反対側にフローし直される。
</div>

文書は左横書きとする。 文書内で左浮動体より先に現れる内容であっても,現在の行に配置される部分は、 浮動体が左へ浮動するに伴い,その右脇へ移動することになる:

浮動体の現在の行に配置される行内内容は、浮動する方向 (左浮動体) の反対側にフローし直される。
利用中のブラウザによる,上の HTML の実際の呈示。
浮動体の現在の行に配置される行内内容は、浮動する方向 (右浮動体) の反対側にフローし直される。
上の例の 左浮動体右浮動体float: right )に変えたときの呈示。

複数の浮動体が,同じ行上で互いに隣接し得る — このモデルは、 それらの浮動体にも適用される。 Several floats may be adjacent, and this model also applies to adjacent floats in the same line.

【 この例は,この訳による追加。 】

次の行内レベルの内容に対し:

ろはほへぬるつねしゑひも

文字 “” は左に浮動させ( floatleft ),文字 “” は右に浮動させた( right )とする。 複数の浮動体が同じ行に配置され、 同じ行にて,浮動体の前/後に現れるテキストは、 浮動体の反対側の脇にフローし直される:

ろはほへぬるつねしゑひも
利用中のブラウザによる呈示。

上の例から更に,すべての浮動体に下端ボーダーを加えて縦幅を増やした場合 — 浮動体は、 先行する他の浮動体の側方に空きがある限り,なるべく上方へ寄せられる:

ろはほへぬるつねしゑひも
利用中のブラウザによる呈示。

次の規則は、 class="icon" を伴うすべての img ボックスを左方へ浮動させる(加えて,左端マージンも 0 に設定する): The following rule floats all IMG boxes with class="icon" to the left (and sets the left margin to 0):

img.icon { 
  float: left;
  margin-left: 0;
}

次の HTML ソースとスタイルシートを考える: Consider the following HTML source and style sheet:

<body>
  <p><img src=img.png alt="浮動する画像">
     これは見本テキストであって、...
</body>

CSS :

img { float: left }
body, p, img { margin: 2em 1em; }

img ボックスは左方へ浮動される。 後続する内容は、 浮動体の右方に,浮動体の現在の行から開始するように整形される。 浮動体の右方に来る行ボックスたちは、 浮動体が在ることに因り短縮されるが、 浮動体を過ぎて以降は, “通常の” 横幅( p 要素により確立される包含ブロックのそれ)に戻る。 この文書は、 次の様に整形されるであろう: The IMG box is floated to the left. The content that follows is formatted to the right of the float, starting on the same line as the float. The line boxes to the right of the float are shortened due to the float’s presence, but resume their "normal" width (that of the containing block established by the P element) after the float. This document might be formatted as:

max( B, P )
B P
P B
img
これは見本テキストであって、浮動要素が,親の中で その マージン, ボーダー, パディング は尊守しつつ,左/右に移動されることを示す以外の目的はない。 これは見本テキストであって、浮動要素が,親の中で その マージン, ボーダー, パディング は尊守しつつ,左/右に移動されることを示す以外の目的はない。
浮動ボックスが,相互作用する様子を示す図。 図の B, P は、 順に body, p のマージンを表す。 浮動しない要素の間では,連接する縦方向のマージンが相殺される一方で、 浮動体( img )のマージン(図の黄色の枠)は、 他と相殺されない。 Image illustrating how floating boxes interact with margins.

HTML が次であったとしても、 整形は正確に同じになる: Formatting would have been exactly the same if the document had been:

<body>
  <p>これは見本テキストであって、
  <img src=img.png alt="この画像は浮動体の説明用。">
           ...
</body>

何故なら、 浮動体の左方に来る現在の行上の内容は,浮動体の右脇から下へフローするように配置し直されるので。 because the content to the left of the float is displaced by the float and reflowed down its right side.

§ マージンの相殺法に言明されたとおり、 浮動ボックスのマージンと他のボックスのマージンとが相殺されることは、 決してない。 したがって,この例においては、 p ボックスと, 浮動された img ボックスとの合間の縦方向マージンが相殺されることはない。 As stated in section 8.3.1, the margins of floating boxes never collapse with margins of adjacent boxes. Thus, in the previous example, vertical margins do not collapse between the P box and the floated IMG box.

浮動体は、 通常フローの下でも,他のボックスと重なり合うことはある(例:浮動体の側方に重なり合うような 通常フローに属するボックスがあって,その横方向マージンが負である場合など)。 その際の塗り順序については、 積層文脈を見よ。 The contents of floats are stacked as if floats generated new stacking contexts, except that any positioned elements and elements that actually create new stacking contexts take part in the float’s parent stacking context. A float can overlap other boxes in the normal flow (e.g., when a normal flow box next to a float has negative margins). When this happens, floats are rendered in front of non-positioned in-flow blocks, but behind in-flow inlines.

通常フローの下で,浮動体が他の要素のボーダーと重なり合う場合に何が起こるかを,次の図に示す: Here is another illustration, showing what happens when a float overlaps borders of elements in the normal flow.

最初の段落を成す見本テキストがこの中にフローされている。 ソースのこのあたりには
浮動する画像がある。 画像は縦に長いので、 この段落より下へ突き出る。
ゆえに、 2 番目の段落も影響されることになる。 この中のどの行内ボックスも,画像のマージンより内側に侵入することは禁制されているので、 “脇へ押し出される”。 段落のボックスは,依然として矩形であるが、 そのボーダーと背景は,浮動している画像の背後に隠される。
浮動している画像は、 それに重なり合うブロックボックスのボーダー(図の赤線)を覆う。 図の灰色の点線は外縁辺(マージン辺), 細い青線が内縁辺(内容辺)を表す。 Image showing a floating image that overlaps the borders of two paragraphs: the borders are interrupted by the image.A floating image obscures borders of block boxes it overlaps.

clear プロパティを利用して,内容を浮動体の側方にフローさせなくする方法を、 次の例で図解する。 The following example illustrates the use of the clear property to prevent content from flowing next to a float.

上の例に、 次の規則が加えられたとするとき: Assuming a rule such as this:

p { clear: left }

整形は、 次の様になるであろう: formatting might look like this:

最初の段落を成す見本テキストがこの中にフローされている。 ソースのこのあたりには
浮動する画像がある。 画像は縦に長いので、この段落より下へ突き出る。

clearance
この段落は、先行するどの左浮動体のマージン辺よりも下に来るように, clear プロパティが left に設定されている。 段落の上端マージンの上には clearance が加えられる。
両段落とも、 clearleft に設定されることにより、 2 番目の段落は,浮動体の下へ “押出される” 。 この効果は、 段落の上端マージンの上に “clearance ” を追加することで成し遂げられる ( clear プロパティを見よ)。 Both paragraphs have set 'clear: left', which causes the second paragraph to be "pushed down" to a position below the float — "clearance" is added above its top margin to accomplish this (see the clear property).

9.5.1. 浮動体の位置決め: float プロパティ

名前 float
left | right | none
初期値 none
適用対象 すべての要素 — ただし、 絶対的に位置された要素は除く(注釈文を見よ)。†
継承 されない
百分率 受容しない
算出値 指定されたキーワード — ただし、 注釈文を見よ。
正準的順序 文法に従う

このプロパティは、 ボックスが浮動すべきかどうか,浮動するならば[ 左方, 右方 ]どちらへ浮動するかを指定する。 どの要素にも設定し得るが、 絶対的に位置されたボックスを生成する要素には適用されず, その算出値も改められることになる — § 9.7を見よ。 This property specifies whether a box should float to the left, right, or not at all. It may be set for any element, but only applies to elements that generate boxes that are not absolutely positioned.\

【† CSS 2 に限らなければ、 適用されないものは他にもある。 CSS 2 では定義されない多くのレイアウトモデル(例:flex レイアウト)においては、 このプロパティは,それらの整形文脈に関与するボックス(例:flex アイテム)には適用されない。 】

各種値の意味は: The values of this property have the following meanings:

left
要素は、 左へ浮動するボックス — 左方へ浮動されるブロックボックス — を生成する。 周りの内容は、 ボックスの右脇に, かつ ボックスの上端からフローする( clear プロパティの対象になる)。 The element generates a block box that is floated to the left. Content flows on the right side of the box, starting at the top (subject to the clear property).
right
要素は、 右へ浮動するボックス — 右方へ浮動されるブロックボックス — を生成する。 周りの内容は、 ボックスの左脇に, かつ ボックスの上端からフローする( clear プロパティの対象になる)。 Similar to left, except the box is floated to the right, and content flows on the left side of the box, starting at the top.
none
ボックスは浮動されない。 The box is not floated.

UA は、 根要素に対しては,その floatnone に扱ってもよい。 User agents may treat float as none on the root element.

浮動体のふるまいは、 以下に与える規則で統制されるものとする — 尚,以下の規則においては:

  • 他の浮動体も含め,どのボックスも、 規則が対象にする浮動体と同じブロック整形文脈に関与するものに限るとする。
  • 浮動体の[ 上端/右端/下端/左端 ]は、 外縁辺を指すとする。

【 原文には明示的に述べられていないが、 以下の規則は,相対位置決めより先に適用される。 】

Here are the precise rules that govern the behavior of floats:
  1. 所与の左へ浮動するボックス L に対し :L の左端は, L包含ブロックの左端より左に位置しない

    右へ浮動するボックスについても相似的な規則が課されるとする。

    The left outer edge of a left-floating box may not be to the left of the left edge of its containing block. An analogous rule holds for right-floating elements.
  2. 所与の左へ浮動するボックス L1, L2 に対し, L1L2先行するならば、 ↓ が満たされる:

    • L1 の右端は, L2 の左端より右に位置しない
    • L1 の下端は, L2 の上端より下に位置しない

    右へ浮動するボックスについても相似的な規則が課されるとする。

    If the current box is left-floating, and there are any left-floating boxes generated by elements earlier in the source document, then for each such earlier box, either the left outer edge of the current box must be to the right of the right outer edge of the earlier box, or its top must be lower than the bottom of the earlier box. Analogous rules hold for right-floating boxes.
  3. 所与の左へ浮動するボックス L, 右へ浮動するボックス R に対し, L, R側方が重なり合うならば :L の右端は, R の左端より右に位置しない The right outer edge of a left-floating box may not be to the right of the left outer edge of any right-floating box that is next to it. Analogous rules hold for right-floating elements.
  4. 所与の浮動ボックス F に対し :F の上端は、 F包含ブロックの上端より上に位置しない A floating box’s outer top may not be higher than the top of its containing block.\
  5. 相殺される 2 つのマージンの合間にある浮動体は、[ そのフローの一部を成す,浮動体の他は内容が空な匿名ブロックボックスである親 ]があるかのように位置される。 【浮動体の現在の行は、この親に包含される縦幅 0 の行ボックスになる。】 そのような親の位置は、 § マージン相殺の規則にて定義される。
    <div style="margin-bottom:1em;">ブロック</div>
    <span style="float:left;">左へ浮動するボックス</span>
    <div style="margin-top:1em;">ブロック</div>
    
    ブロック
    左へ浮動するボックス
    ブロック
    When the float occurs between two collapsing margins, the float is positioned as if it had an otherwise empty anonymous block parent taking part in the flow. The position of such a parent is defined by the rules in the section on margin collapsing.
  6. 所与の浮動ボックス F, および F先行するブロックボックス浮動ボックスB に対し :F の上端は B の外縁上端辺より上に位置しない The outer top of a floating box may not be higher than the outer top of any block or floated box generated by an element earlier in the source document.
  7. 所与の浮動ボックス F, および[ F先行する あるボックスを包含している行ボックス B ]に対し :F の上端は B の上端 より上に位置しない The outer top of an element’s floating box may not be higher than the top of any line-box containing a box generated by an element earlier in the source document.
  8. 所与の左へ浮動するボックス L に対し, L の左端が,包含ブロックの左端に接していないならば† :L の右端は,包含ブロックの右端より右に位置しない

    右へ浮動するボックスについても相似的な規則が課されるとする。

    A left-floating box that has another left-floating box to its left may not have its right outer edge to the right of its containing block’s right edge. (Loosely: a left float may not stick out at the right edge, unless it is already as far to the left as possible.) An analogous rule holds for right-floating elements.
  9. clear が設定された浮動体に対する 追加の拘束。 】
  10. 以上による制約の下で、 浮動ボックスは 可能な限り上方に配置する。 A floating box must be placed as high as possible.
  11. 前項も含め,以上による制約の下で、[ 左へ浮動する/右へ浮動する ]ボックスは 可能な限り[ 左方/右方 ]に配置する。 A left-floating box must be put as far to the left as possible, a right-floating box as far to the right as possible. A higher position is preferred over one that is further to the left/right.

【† 原文では次の様に記されている: 】

“所与の左へ浮動するボックス L1, L2 に対し, L1L2先行する, かつ L2L1 の右にあるならば: L2 の右端外縁辺は,包含ブロックの右端辺より右に位置しない (くだけて言えば、 可能な限り左方に来ていない左浮動体は,包含ブロックの右端を突き出てはならない)”

しかしながら、 L1 の横幅が 0 の場合は,例外とされるべきであろう ( “くだけて言えば” 以下の部分が正しいふるまいとされるべき)。 例えば:

<div style="width: 10em; border:solid thin;">
  <div style="float:left; height:1em; outline:solid red;"
  ><!-- 左浮動体1(横幅 0 ) --></div>
  <div style="float:left; width: 20em;"
  >左浮動体2(横幅は包含ブロックのそれを超える)</div>
…
</div>
左浮動体2(横幅は包含ブロックのそれを超える)
利用中のブラウザによる上の HTML の呈示。 原文の規則に従うなら、 2 番目の左浮動体は最初の浮動体(図の赤線)の下端より下に来なければならない。

ただし,CSS 2 においては、 次の様な浮動体 F の位置は未定義である: [ F と同じブロック整形文脈に属する, フロー内にある負な縦方向マージン ]があって,[ そのようなマージンすべてが 0 に設定された ]とするとき、 F の位置がより上になる。 But in CSS 2, if, within the block formatting context, there is an in-flow negative vertical margin such that the float’s position is above the position it would be at were all such negative margins set to zero, the position of the float is undefined.↑↑References to other elements in these rules refer only to other elements in the same block formatting context as the float.

次の HTML 断片により、 b は右端へ浮動される。 This HTML fragment results in the b floating to the right.

<p>a<span style="float: right">b</span></p>

p 要素の横幅が十分あれば、 a と b は次の様に横並びにされる: If the P element’s width is enough, the a and the b will be side by side. It might look like this:

a
b
p が生成するボックス(点線)の中で、 左に位置する a と, 浮動して右へ寄せられる b An a at the left side of a box and a b at the right side

9.5.2. 浮動体の脇へのフローの制御法: clear プロパティ

名前 clear
none | left | right | both
初期値 none
適用対象 ブロックレベルの要素
継承 されない
百分率 受容しない
算出値 指定されたキーワード
正準的順序 文法に従う

このプロパティは、 要素の clear 対象 とされる浮動ボックスたちを指示する:

【 “clear 対象” は、 この訳で新たに導入した用語である。 その理由は、 原文の “clear する” という動詞としての用法を日本語で表現するためには,その目的語 — すなわち,clear 対象 — に変形した方が都合がよいこと、 および,このように定義した方が本文を簡潔に記述できるからである。 】

This property indicates which sides of an element’s box(es) may not be adjacent to an earlier floating box. The clear property does not consider floats inside the element itself or in other block formatting contexts.

要素の clear 対象は、 clear の値に応じて,次で与えられる: Values have the following meanings when applied to non-floating block-level boxes:

left
要素に先行するすべての左へ浮動するボックス。 Requires that the top border edge of the box be below the bottom outer edge of any left-floating boxes that resulted from elements earlier in the source document.
right
要素に先行するすべての右へ浮動するボックス。 Requires that the top border edge of the box be below the bottom outer edge of any right-floating boxes that resulted from elements earlier in the source document.
both
要素に先行するすべての浮動ボックス。 Requires that the top border edge of the box be below the bottom outer edge of any right-floating and left-floating boxes that resulted from elements earlier in the source document.
none
空集合 (すなわち、 ボックスの位置には,以下に述べる拘束は適用されないことを意味する)。 No constraint on the box’s position with respect to floats.

【 この節の以下の記述は、 下の例の終わりまで,浮動体でない要素を対象にする。 】

none 以外の値に対しては、 clearance が導入され得る。 clearance は、 マージン相殺を妨げつつ,要素の margin-top の上方におけるアキ組として動作する。 それは、 浮動体の側方に重なり合わない所まで,要素を下方へ押出すために利用される。 Values other than none potentially introduce clearance. Clearance inhibits margin collapsing and acts as spacing above the margin-top of an element. It is used to push the element vertically past the float.

要素の 仮の位置 とは、 要素が[ その clear プロパティが none である下で配置されたとき ]の,上端ボーダー辺として与えられる。 要素は、 その 仮の位置 が,要素の clear 対象に含まれている いずれかの浮動体の側方にあるとき、 clearance を持つ とされ、 clearance が導入されることになる (必然的に、 要素の clear の算出値は,非 none である必要がある)。 Computing the clearance of an element on which clear is set is done by first determining the hypothetical position of the element’s top border edge. This position is where the actual top border edge would have been if the element’s clear property had been none.

要素が clearance を持つ場合、 要素とその周りの要素によるマージン相殺のふるまいも, § マージンの相殺法に則って変化し、 clearance の量は,次のいずれかのふるまいにより設定される: If this hypothetical position of the element’s top border edge is not past the relevant floats, then clearance is introduced, and margins collapse according to the rules in 8.3.1.

  • ふるまい A: clearance を,次に挙げる 2 つの量の最大に設定する: Then the amount of clearance is set to the greater of:

    1. 要素が生成するブロックの上端ボーダー辺を[ clear 対象の浮動体の下端外縁辺のうち,最も下方にある位置 ]に配置するために必要とされる量。

      clearance がこの量で与えられる場合、 ブロックの上端マージンは,ブロックの上端位置に影響しなくなることになる。 】

      The amount necessary to place the border edge of the block even with the bottom outer edge of the lowest float that is to be cleared.
    2. ブロックの上端ボーダー辺を 仮の位置 に配置するために必要とされる量。

      仮の位置 は浮動体の側方にある筈なので,何のために この量も得る必要があるのか不思議に見えるが、 このことは,clearance が導入される — すなわち,要素の上端マージンが他と相殺されなくなる — と同時に,その副作用として浮動体の上端位置も変わり得ることを意味する(下の例を見よ)。 】

      The amount necessary to place the top border edge of the block at its hypothetical position.
  • ふるまい B: clearance を,単にふるまい A の最初の項で与えられる量に設定する。 Alternatively, clearance is set exactly to the amount necessary to place the border edge of the block even with the bottom outer edge of the lowest float that is to be cleared.

注記: いずれのふるまいも、 既存の Web 内容との互換性に関する評価を待っているため,許容されている。 将来の CSS 仕様は、 このいずれか, または他のふるまいを要求することになる。 Note: Both behaviors are allowed pending evaluation of their compatibility with existing Web content. A future CSS specification will require either one or the other.

注記: clearance は 0 以下にもなり得る。 Note: The clearance can be negative or zero.

【 clearance の計算例。以下、この例の和訳は省略する。】
【 clearance が負になり得る例。以下、この例の和訳は省略し,次の例に差し替える。】

次の HTML が与えられた下では:

<div style="line-height:1.2em;">
  <div style="margin-bottom:4em; border:solid 0.4em pink;"
  >ブロック1</div>
  <div>
    <mark style="float:left;">(浮動体)</mark>
    <div style="margin-top:1em; border:solid 0.4em pink;"
    >ブロック2</div>
  </div>
</div>

ブロック1とブロック2のマージンは相殺され,ブロック1の下端ボーダー辺とブロック2の上端ボーダー辺との間隔は、[ ブロック1の下端マージンとブロック2の上端マージンの最大 ] = 4em になる。 浮動体の現在の行の上端は、 ブロック2の親 div の上端内縁辺(図の点線)に位置する(ブロック2のボーダー辺に一致する):

ブロック1
(浮動体)
ブロック2
利用中のブラウザによる上の HTML の呈示。 太い線は、 ブロック1/2のボーダー。

ブロック2のスタイルに clear: left を追加したとする。 その呈示は、 次の様になる:

ブロック1
(浮動体)
ブロック2
ブロック2に clear: left を追加したときの,利用中のブラウザによる呈示

マージンは相殺されなくなり、 ブロック2は浮動体の下に来る。 ブロック1のマージンが浮動体との間を隔てる結果,浮動体の位置はそのままになるので、 clearance は,ふるまい A, B いずれにせよ ( ( 浮動体の縦幅 ) − ( ブロック2の上端マージン ) ) になる。

上の HTML にて、 今度は,ブロック1の下端マージンとブロック2の上端マージンを入れ替えたとする:

<div style="line-height:1.2em;">
  <div style="margin-bottom:1em; border:solid 0.4em pink;"
  >ブロック1</div>
  <div>
    <mark style="float:left;">(浮動体)</mark>
    <div style="margin-top:4em; border:solid 0.4em pink;"
    >ブロック2</div>
  </div>
</div>

その呈示は,入れ替える前と同じになるが、 ブロック2のスタイルに clear: left を追加したときの呈示は, 次の様になる:

ブロック1
(浮動体)
ブロック2
clear の効果により,浮動体の位置が変化する図。

マージンが相殺されなくなるに伴い、 浮動体の現在の行の位置(図の点線)は, ブロック2の上端ボーダーからブロック1の下端マージン辺へ移動する。 浮動体の縦幅が図のように小さければ: ふるまい A の下では、 ブロック2の位置は そのまま維持されることになる。 ふるまい B の下では、 ブロック2の上端が浮動体の下端に接合され,元の位置より上に移動することになる。

clear プロパティが浮動要素に設定されたときは、 浮動体の位置決め規則に次の拘束も追加される: When the property is set on floating elements, it results in a modification of the rules for positioning the float. An extra constraint (#10) is added:

  • 所与の浮動体 F に対し :F の上端 外縁辺は、 Fclear 対象である,どの浮動体の下端 外縁辺よりも上に位置しない The top outer edge of the float must be below the bottom outer edge of all earlier left-floating boxes (in the case of 'clear: left'), or all earlier right-floating boxes (in the case of 'clear: right'), or both ('clear: both').

注記: clear プロパティは、 [CSS1] においては 【行内レベルも含め】 すべての要素に適用される — したがって、 すべての要素上でこのプロパティをサポートする実装もある。 [ [CSS20] /CSS 2 ]においては、 ブロックレベルの要素のみに適用される。 したがって、 作者は,このプロパティをブロックレベルの要素に限って利用するべきである。 clear行内レベルの要素 上でもサポートする実装は、 上に説明した clearance を設定するのでなく,分断を強制するべきである — 実質的には、 空な行ボックスを一つ以上挿入する (または、 § 9.5 にて述べたとおり,新たな行ボックスを下方へずらす) ことにより、[ clearance を持つような行内レベルの要素を含んでいる行ボックス ]の上端を clear 対象の どの浮動ボックスよりも下へ移動させる ]ことになる。 Note. This property applied to all elements in CSS1. Implementations may therefore have supported this property on all elements. In CSS2 (1998) and CSS 2 the clear property only applies to block-level elements. Therefore authors should only use this property on block-level elements. If an implementation does support clear on inline elements, rather than setting a clearance as explained above, the implementation should force a break and effectively insert one or more empty line boxes (or shifting the new line box downward as described in section 9.5) to move the top of the cleared inline’s line box to below the respective floating box(es).

9.6. 絶対位置決め

【 この節の内容は、 今や [CSS-POSITION-3] § 絶対位置決め に包摂されるので,和訳は省略する。 】

9.7. display, position, float の関係性

ボックスの生成とレイアウトに影響する 3 種のプロパティ — display, position, float — は、 次の様に相互作用する【以下における各プロパティは、当のボックスの それを指す】The three properties that affect box generation and layout — display, position, and float — interact as follows:

  1. display の指定値は none ならば :要素はボックスを生成しないので,[ position, float ]は適用されない。 If display has the value none, then position and float do not apply. In this case, the element generates no box.
  2. 他の場合, position の指定値は[ absolutefixed ]ならば :ボックスは絶対的に位置される(ボックスの位置は,各種インセットプロパティとボックスの包含ブロックから決定される)。 float の算出値は none になり, display の算出値は 下の表に従う。 Otherwise, if position has the value absolute or fixed, the box is absolutely positioned, the computed value of float is none, and display is set according to the table below. The position of the box will be determined by the top, right, bottom and left properties and the box’s containing block.
  3. 他の場合, float の指定値は none 以外【かつ float はボックスに適用される】ならば :ボックスは浮動され, display の算出値は 下の表に従う。 Otherwise, if float has a value other than none, the box is floated and display is set according to the table below.
  4. 他の場合,要素は根要素であるならば :display の算出値は 下の表に従う。 ただし、 display の指定値が list-item の場合に その算出値が[ block, list-item ]どちらになるかは、 CSS 2 においては未定義である。 Otherwise, if the element is the root element, display is set according to the table below, except that it is undefined in CSS 2 whether a specified value of list-item becomes a computed value of block or list-item.
  5. 他の場合 :display プロパティの指定値が,そのまま算出値になる。 Otherwise, the remaining display property values apply as specified.
指定値 算出値
inline-table table
<table-*> block
inline block
inline-block block
inline-flexflex
inline-gridgrid
ruby-baseblock
ruby-textblock
ruby-base-containerblock
ruby-text-containerblock
その他 指定値
Specified value|Computed value inline-table|table inline, table-row-group, table-column, table-column-group, table-header-group, table-footer-group, table-row, table-cell, table-caption, inline-block|block others|same as specified

【 “†” が付与された行は、 他の各種 CSS モジュール(flex レイアウトなど)による拡張 — これらは、 この訳による補完であり, 網羅的ではないかもしれない。 】【 参考: ボックス型の自動的な変形

9.8. 通常フロー, 浮動体, 絶対位置決めの比較

【 この節の和訳は,省略する。 】

9.9. 多層化された呈示

9.9.1. 積層レベルの指定法: z-index プロパティ

名前 z-index
auto | <integer>
初期値 auto
適用対象 有位置な要素
継承 されない
百分率 受容しない
算出値 指定されたとおり
正準的順序 文法に従う

z-index プロパティは、 要素が生成する有位置なボックスに対し,次を指定する: For a positioned box, the z-index property specifies:

  • ボックスが属している積層文脈における,ボックスの積層レベルThe stack level of the box in the current stacking context.
  • ボックスは積層文脈を確立するかどうか。 Whether the box establishes a stacking context.

各種値の意味は: Values have the following meanings:

<integer>
生成されるボックスは、 新たな積層文脈を確立する。 ボックスの積層レベルは,所与の整数になる。 This integer is the stack level of the generated box in the current stacking context. The box also establishes a new stacking context.
auto
生成されるボックスの積層レベルは, 0 になる。 ボックスは、 根要素でない限り,新たな積層文脈を確立しない†。 The stack level of the generated box in the current stacking context is 0. The box does not establish a new stacking context unless it is the root element.
【† このプロパティによる効果としては。 積層文脈は、 他の要因により確立される場合もある。 】

この節の表記 “手前” は、 利用者が面するスクリーンから,利用者に近づく方を意味する In this section, the expression "in front of" means closer to the user as the user faces the screen.

CSS 2 においては、 各ボックスは,[ 横方向, 縦方向 ]位置に加え, “z-軸” 方向(スクリーン面から垂直に利用者に近づく方向)の位置 — 略して z-位置 — も持つ。 z-位置は、 特にボックスどうしが視覚的に重なり合う場合に関わり, 整形する際の他のボックスによる層との重なり順を表す。 この節は、 各ボックスが z-軸沿いのどこに位置されるかについて論じる。 In CSS 2, each box has a position in three dimensions. In addition to their horizontal and vertical positions, boxes lie along a "z-axis" and are formatted one on top of the other. Z-axis positions are particularly relevant when boxes overlap visually. This section discusses how boxes may be positioned along the z-axis.

描画ツリーがキャンバスに塗られる順序は、 積層文脈を通して述べられる。 積層文脈は、 別の積層文脈を包含し得る†。 積層文脈は、 その親の積層文脈の視点からは不可分である — それらのボックスたちの合間に,他の積層文脈に属するボックスが来ることはない††。 The order in which the rendering tree is painted onto the canvas is described in terms of stacking contexts. Stacking contexts can contain further stacking contexts. A stacking context is atomic from the point of view of its parent stacking context; boxes in other stacking contexts may not come between any of its boxes.

【† すなわち、 各 積層文脈は,ボックスツリーの中の ある下位ツリーを表現する。 】【†† すなわち、 親積層文脈の視点からは,不可分な一枚の層(=末端の子孫)として扱われる。 】

どのボックスも,ある一つの 積層文脈 に所属する。 所与の積層文脈に属する,どの有位置なボックスも、 整数をとる 積層レベル を持つ (負にもなり得る)。 それは、 同じ積層文脈に属する他のボックスの積層レベルに相対的な, z-位置を与える — 同じ積層文脈の中では:

  • ボックスたちは、 積層レベルがより高いものほど,手前の層に整形される。
  • 積層レベルが同じボックスたちは、 ツリー順序に則って,奥から手前にかけて積層される。
Each box belongs to one stacking context. Each positioned box in a given stacking context has an integer stack level, which is its position on the z-axis relative other stack levels within the same stacking context. Boxes with greater stack levels are always formatted in front of boxes with lower stack levels. Boxes may have negative stack levels. Boxes with the same stack level in a stacking context are stacked back-to-front according to document tree order.

根要素は、 根積層文脈積層文脈たちが成すツリーの根】を形成する。 他の積層文脈は、 有位置な要素(相対的に位置された要素も含む)のうち z-index の算出値が auto 以外をとるものにより生成される。 積層文脈は、 包含ブロックに関係するとは限らない。 将来レベルの CSS では、 他のプロパティからも積層文脈が導入され得る — 例えば opacity課題 #2717 も見よ。】 The root element forms the root stacking context. Other stacking contexts are generated by any positioned element (including relatively positioned elements) having a computed value of z-index other than auto. Stacking contexts are not necessarily related to containing blocks. In future levels of CSS, other properties may introduce stacking contexts, for example opacity [CSS3COLOR].

積層文脈の中では、 次に挙げる各層が,挙げられる順に, 奥から手前の順序で塗られる: Within each stacking context, the following layers are painted in back-to-front order:

  1. 積層文脈を確立している要素の[ 背景とボーダー ]。 the background and borders of the element forming the stacking context.
  2. 積層文脈のうち,積層レベルが負なもの(最も負なものが最初)。 the child stacking contexts with negative stack levels (most negative first).
  3. 有位置でない子孫たち — 次の順に塗られる:

    1. フロー内にある, かつ 行内レベルでないもの。 the in-flow, non-inline-level, non-positioned descendants.
    2. 浮動体。 ( A ) the non-positioned floats.
    3. フロー内にある, かつ 行内レベルであるもの。 ( B ) the in-flow, inline-level, non-positioned descendants, including inline tables and inline blocks.
  4. [ 子積層文脈有位置な子孫 ]のうち,積層レベルが 0 のもの。 ( C ) the child stacking contexts with stack level 0 and the positioned descendants with stack level 0.
  5. 積層文脈のうち,積層レベルが正なもの(最も正なものが最後)。 the child stacking contexts with positive stack levels (least positive first).

ただし、 次に挙げる【子積層文脈を確立しない】要素は, 要素自身が新たな積層文脈を生成したかのように塗られる — その[ 有位置な子孫, および 子積層文脈 ]は、 要素が属する積層文脈の一部を成すことを除いて:

【 すなわち,これらの要素は、 各要素ごとに,その内容から[ 有位置な子孫/積層文脈を成す下位ツリー ]は除外した部分が,上の手続きに従って不可分な一枚の層に塗られる (具体的には、段 1 と段 3 のみ関わる)。 この結果の各層と, 除外されたものたちが、 要素が属する積層文脈の下で,上の手続きに従って塗られることになる。 】

Within each stacking context, positioned elements with stack level 0 (in layer 6), non-positioned floats (layer 4), inline blocks (layer 5), and inline tables (layer 5), are painted as if those elements themselves generated new stacking contexts, except that their positioned descendants and any would-be child stacking contexts take part in the current stacking context.

この塗り順序は、 各積層文脈に対し,再帰的に適用される。 この,積層文脈の塗り順序の記述は、 付録 E による詳細な規範的定義の概観である。 This painting order is applied recursively to each stacking context. This description of stacking context painting order constitutes an overview of the detailed normative definition in Appendix E.

【 この例は,この訳による追加。 】

塗り順序が適用されるのは、 要素ツリーからボックスツリーに組み替えられた後になる。 次の様な HTML があるとき:

<div style="z-index:-1">
  <div style="position:fixed; z-index:1; ..."
  >固定的に位置された内容</div>
</div>

固定的に位置された要素は, ボックスツリーにおいては根の直下に移動されるので、 この HTML の “固定的に位置された内容” は, 親 div積層レベルを問わず,[ 根要素が確立する積層文脈の中で,積層レベルが 0 になるもの ]より手前に塗られることになる。

次の例では、 ( "id" 属性で命名された)各ボックスの積層レベルは,[ "text2" は 0, "image" は 1, "text3" は 2, "text1" は 3 ]になる。 "text2" の積層レベルは、 根ボックスから継承される。 他のものは z-index プロパティで指定されている。 In the following example, the stack levels of the boxes (named with their "id" attributes) are: "text2"=0, "image"=1, "text3"=2, and "text1"=3. The "text2" stack level is inherited from the root box. The others are specified with the z-index property.

<html lang="ja">
  <head>
    <meta charset="utf-8">
    <title>z-位置の用例</title>
    <style type="text/css">
      .pile { 
        position: absolute; 
        left: 2in; 
        top: 2in; 
        width: 3in; 
        height: 3in; 
      }
    </style>
  </head>
  <body>
    <img id="image" class="pile" 
         src="butterfly.png" alt="見本画像"
         style="z-index: 1"
    >

    <div id="text1" class="pile" 
         style="z-index: 3"
    >
      
このテキストは、
見本画像より手前の層に来る
This text will overlay the butterfly image.
    </div>

    <div id="text2">
      
このテキストは、
一番奥の層に来る
This text will be beneath everything.
    </div>

    <div id="text3" class="pile" 
         style="z-index: 2"
    >
      
このテキストは、
text1 より奥, かつ見本画像より手前の層に来る
This text will underlay text1, but overlay the butterfly image
    </div>
  </body>
</html>

この例は、 透明度の観念をデモる。 背景に対する既定のふるまいでは、 背後にあるボックスは可視にされる。 この例では、 各ボックスは,下層のボックスの上層に透明に重ねられる。 このふるまいは、 既存の各種 背景プロパティ のいずれかを利用して上書きできる。 This example demonstrates the notion of transparency. The default behavior of the background is to allow boxes behind it to be visible. In the example, each box transparently overlays the boxes below it. This behavior can be overridden by using one of the existing background properties.

9.10 テキスト方向: direction, unicode-bidi プロパティ

双方向テキストをサポートしない適合 UA は、 この節にて述べる[ direction, unicode-bidi ]プロパティを無視してもよい。 この例外には、[ 単に、 システムのフォントがサポートするがため,右横書き文字を描画し得る ]が,右横書きテキスト方向の概念はサポートしない UA も含まれる。 Conforming user agents that do not support bidirectional text may ignore the direction and unicode-bidi properties described in this section. This exception includes UAs that render right-to-left characters simply because a font on the system contains them but do not support the concept of right-to-left text direction.

【 以下,この節の内容は、 今や [CSS-WRITING-MODES-4] § 行内方向と双方向性, § direction プロパティ, § unicode-bidi プロパティ に包摂されるので,和訳は省略する ( CSS 2 では、 縦書きはサポートされない)。 】

10. 視覚整形モデルの詳細

10.1. 包含ブロックの定義

要素が生成するボックス(たち)の位置とサイズは、 要素の 包含ブロック と呼ばれる,ある矩形に相対的に計算されることもある ( § 包含ブロックを見よ)。 それは、 以下に従って定義される: The position and size of an element’s box(es) are sometimes calculated relative to a certain rectangle, called the containing block of the element. The containing block of an element is defined as follows:

  • 根要素の包含ブロックは、 初期包含ブロック と呼ばれる矩形になる。 それは、 連続的媒体用には,[ 表示域の寸法と同じ, かつ その原点がキャンバスの原点に一致する矩形 ]になり、 ページ化媒体用には,ページ区画になる。 初期包含ブロックの direction プロパティは、 根要素用のそれと同じになる。 The containing block in which the root element lives is a rectangle called the initial containing block. For continuous media, it has the dimensions of the viewport and is anchored at the canvas origin; it is the page area for paged media. The direction property of the initial containing block is the same as for the root element.
  • 他の場合、 要素は絶対的に位置されるならば (すなわち,要素の positionfixedabsolute ) :[CSS-POSITION-3] § 有位置なボックスの包含ブロック にて定義される(なので、この訳では省略する)。】
  • 他の場合の包含ブロックは、 要素に最も近い[ ブロックコンテナである先祖ボックス ]の内容辺で形成される。 【 CSS 2 においては。より一般には,要素が関与する整形文脈により定義される。】 For other elements, if the element’s position is relative or static, the containing block is formed by the content edge of the nearest block container ancestor box.If the element has 'position: fixed', the containing block is established by the viewport in the case of continuous media or the page area in the case of paged media.If the element has 'position: absolute', the containing block is established by the nearest ancestor with a position of absolute, relative or fixed, in the following way:In the case that the ancestor is an inline element, the containing block is the bounding box around the padding boxes of the first and the last inline boxes generated for that element. In CSS 2, if the inline element is split across multiple lines, the containing block is undefined.Otherwise, the containing block is formed by the padding edge of the ancestor.If there is no such ancestor, the containing block is the initial containing block.

ページ化媒体においては、 絶対的に位置された要素は 【…以下,この箇所の内容は [CSS-POSITION-3] § 絶対的に位置された要素の断片化法 に述べられているので、この訳では省略する。】 In paged media, an absolutely positioned element is positioned relative to its containing block ignoring any page breaks (as if the document were continuous). The element may subsequently be broken over several pages.For absolutely positioned content that resolves to a position on a page other than the page being laid out (the current page), or resolves to a position on the current page which has already been rendered for printing, printers may place the content • on another location on the current page, • on a subsequent page, or • may omit it.Note that a block-level element that is split over several pages may have a different width on each page and that there may be device-specific limits.

次の文書における各要素の包含ブロックは、 それらが有位置でないならば: With no positioning, the containing blocks (C.B.) in the following document:

<!DOCTYPE html>
<html>
    <head>
        <title>包含ブロックの説明</title>
    </head>
    <body id="body">
        <div id="div1">
        <p id="p1">最初の段落のテキスト...</p>
        <p id="p2">これは、<em id="em1">
        <strong id="strong1">二番目の</strong>段落の中のテキスト</em></p>
        </div>
    </body>
</html>

次に従って確立される: are established as follows:

ボックスを生成する要素 For box generated by 要素の包含ブロックを確立するもの C.B. is established by
html 初期包含ブロック initial C.B. (UA-dependent)
body html
div1 body
p1 div1
p2 div1
em1 p2
strong1 p2

初期包含ブロックは、 UA に依存する。

div1 を次のように有位置にした場合: If we position "div1":

#div1 { position: absolute; left: 50px; top: 50px }

その包含ブロックは、 もはや "body" でなくなり,初期包含ブロックになる (他に有位置な先祖ボックスは無いので)。 its containing block is no longer "body"; it becomes the initial containing block (since there are no other positioned ancestor boxes).

同様に, em1 も次のように有位置にした場合: If we position "em1" as well:

#div1 { position: absolute; left: 50px; top: 50px }
#em1  { position: absolute; left: 100px; top: 100px }

包含ブロックの表は、 次のようになる: the table of containing blocks becomes:

ボックスを生成する要素 For box generated by 要素の包含ブロックを確立するもの C.B. is established by
html 初期包含ブロック initial C.B.
body html
div1 初期包含ブロック initial C.B.
p1 div1
p2 div1
em1 div1
strong1 em1

有位置な em1 の包含ブロックは、 最も近い有位置な先祖ボックス — すなわち, div1 が生成するボックス — になる。 By positioning "em1", its containing block becomes the nearest positioned ancestor box (i.e., that generated by "div1").

10.2. 内容横幅: width プロパティ

名前 width
<length> | <percentage> | auto
初期値 auto
適用対象 すべての要素 — ただし,[ 行内ボックス†, table-row, table-row-group ]は除く。 all elements but non-replaced inline elements, table rows, and row groups
継承 されない
百分率 包含ブロックの横幅を基準にする。 refer to width of containing block
算出値 長さは絶対化される/ 他は指定されたとおり the percentage or auto as specified or the absolute length
正準的順序 文法に従う

【† 原文には “置換されない行内要素( non-replaced inline element )” と記されているが、 この “行内” は(行内レベルではなく)行内ボックスを意味しており,不可分な行内行内ブロックなど)は含まれないので、 より明確に(他の各種 CSS 仕様に倣って) “行内ボックス(を生成する要素)” と記すことにする — このページに現れる,他のすべての “置換されない行内要素” も含め。 】

このプロパティは、 ボックスの内容横幅(内容区画の横幅)を指定する。 This property specifies the content width of boxes.

このプロパティは、 行内ボックスを生成する要素には適用されない。 そのようなボックスの内容横幅は、 その中に描画される内容のそれになる(子が相対的にオフセットされるの)。 行内ボックスたちは、 何個かの行ボックスの中へフローする。 行ボックスの横幅は、 その包含ブロックのそれになるが,浮動体が在る場合は短くされることもある。 This property does not apply to non-replaced inline elements. The content width of a non-replaced inline element’s boxes is that of the rendered content within them (before any relative offset of children). Recall that inline boxes flow into line boxes. The width of line boxes is given by the their containing block, but may be shorted by the presence of floats.

各種 値の意味は: Values have the following meanings:

<length>
単位付きの長さを利用して内容区画の横幅を指定する。 Specifies the width of the content area using a length unit.
<percentage>
百分率による横幅を指定する。 百分率は、 生成されるボックスの包含ブロックの横幅を基準に計算される。 包含ブロックの横幅が 要素の横幅に依存する場合の 結果のレイアウトは、 CSS 2 においては定義されない。 Specifies a percentage width. The percentage is calculated with respect to the width of the generated box’s containing block. If the containing block’s width depends on this element’s width, then the resulting layout is undefined in CSS 2.\
注記: 包含ブロックがブロックコンテナ要素に基づくような絶対的に位置された要素に対しては、 百分率は,その要素のパディングボックスの横幅を基準に計算される。 これは、 百分率による横幅が 常に親要素の内容ボックスを基準に計算されていた [CSS1] からの変更である。 Note: For absolutely positioned elements whose containing block is based on a block container element, the percentage is calculated with respect to the width of the padding box of that element. This is a change from CSS1, where the percentage width was always calculated with respect to the content box of the parent element.
auto
横幅は、 他のプロパティの値に依存する。 以下の各節を見よ。 The width depends on the values of other properties. See the sections below.

width に対する負な値は合法でない。 Negative values for width are illegal.

例えば、 次の規則は,段落の内容横幅を 100 ピクセルに固定する: For example, the following rule fixes the content width of paragraphs at 100 pixels:

p { width: 100px }

10.3. 横幅とマージンの計算法

レイアウトに利用される要素の[ width, margin-left, margin-right, left, right ]プロパティの値は、 互いに依存し,生成されるボックスの種別にも依存する (レイアウトに利用される値は、 使用値とも呼ばれる)。 原則的には、 使用値は,算出値の[ auto を何らかの相応しい値に置換し,百分率値は 包含ブロックに基づいて計算した ]結果と同じになるが、 例外もある。 The values of an element’s width, margin-left, margin-right, left and right properties as used for layout depend on the type of box generated and on each other. (The value used for layout is sometimes referred to as the used value.) In principle, the values used are the same as the computed values, with auto replaced by some suitable value, and percentages calculated based on the containing block, but there are exceptions. The following situations need to be distinguished:inline, non-replaced elementsinline, replaced elementsblock-level, non-replaced elements in normal flowblock-level, replaced elements in normal flowfloating, non-replaced elementsfloating, replaced elementsabsolutely positioned, non-replaced elementsabsolutely positioned, replaced elementsinline-block, non-replaced elements in normal flowinline-block, replaced elements in normal flowFor Points 1-6 and 9-10, the values of left and right in the case of relatively positioned elements are determined by the rules in section 9.4.3.

注記: 以下に計算される width の使用値は、 仮の値であり, min-width, max-width に依存して,複数回 計算する必要が生じることもある。 § 最小, 最大な横幅 を見よ。 Note. The used value of width calculated below is a tentative value, and may have to be calculated multiple times, depending on min-width and max-width, see the section Minimum and maximum widths below.

以下の各節では、 関連する各種プロパティの値を次の記号で表す:

これらの値は、 初期時には,各プロパティの算出値に設定されているとする。 この節の目的は、 これらのうち, 不定なauto をとるものを (拘束され過ぎになる場合も取り扱いつつ) 解決して 使用値を得ることである。

【 原文には,有位置な要素の[ leftright ]の使用値の計算法も含まれているが、 今や [CSS-POSITION-3] にて定義されるので,和訳は省略する (これらは、 他の要素には適用されない)。 】

10.3.X. 各種ボックスに対する横幅の計算法

【 この訳では、 各種ボックスに対する横幅の計算法を,この節の中で一括して与える。 】

  1. 先ず,置換要素に対しては、 不定な W§ 置換要素のサイズ法 に従って解決した上で、 以下を適用する。
  2. 絶対的に位置された要素に対しては、 § 10.3.7 に従うとする。
  3. 他の要素に対しては:

    通常フロー内にある行内レベルの要素
    浮動体

    不定な W は:

    不定な[ mLmR ]は、 0 に解決する。
    通常フロー内にあるブロックレベルの要素
    § 10.3.3 にて与えられる。

10.3.1. 行内ボックスを生成する要素

§ 各種ボックスに対する横幅の計算法 を見よ。 The width property does not apply. A computed value of auto for margin-left or margin-right becomes a used value of 0.

10.3.2. 行内レベルの置換要素

§ 各種ボックスに対する横幅の計算法 を見よ。 A computed value of auto for margin-left or margin-right becomes a used value of 0.If height and width both have computed values of auto and the element also has an intrinsic width, then that intrinsic width is the used value of width.If height and width both have computed values of auto and the element has no intrinsic width, but does have an intrinsic height and intrinsic ratio; or if width has a computed value of auto, height has some other computed value, and the element does have an intrinsic ratio; then the used value of width is: • (used height) * (intrinsic ratio)If height and width both have computed values of auto and the element has an intrinsic ratio but no intrinsic height or width, then the used value of width is undefined in CSS 2. However, it is suggested that, if the containing block’s width does not itself depend on the replaced element’s width, then the used value of width is calculated from the constraint equation used for block-level, non-replaced elements in normal flow.Otherwise, if width has a computed value of auto, and the element has an intrinsic width, then that intrinsic width is the used value of width.Otherwise, if width has a computed value of auto, but none of the conditions above are met, then the used value of width becomes 300px. If 300px is too wide to fit the device, UAs should use the width of the largest rectangle that has a 2:1 ratio and fits the device instead.

10.3.3. 通常フロー内にあるブロックレベルの置換されない要素

結果の mL, W, mR は、 次の等式を満たすように解決するものとする :mL + W + mR = 包含ブロックの横幅 pb

ここで pb は、 横方向のパディング幅, ボーダー幅の算出値の総和を表す (これらのプロパティは、 auto 値をとらず,算出値は常に絶対長さに解決される) :pb = border-left-width + padding-left + padding-right + border-right-width

The following constraints must hold among the used values of the other properties:margin-left + border-left-width + padding-left + width + padding-right + border-right-width + margin-right = width of containing block
W は不定でない:

先ず,[ W + ( 不定でない mL ) + ( 不定でない mR ) > 包含ブロックの横幅 pb ]ならば、 不定な[ mLmR ]は 0 に解決する。 その上で, mL, mR に応じて: If width is not auto and border-left-width + padding-left + width + padding-right + border-right-width (plus any of margin-left or margin-right that are not auto) is larger than the width of the containing block, then any auto values for margin-left or margin-right are, for the following rules, treated as zero.

mL, mR ともに不定でない (この事例は “拘束され過ぎ” ):

包含ブロックの direction プロパティに応じて:

  • ltr ならば: mR を不定とみなして, mR について等式を解いて解決する。
  • rtl ならば: mL を不定とみなして, mL について等式を解いて解決する。
If all of the above have a computed value other than auto, the values are said to be "over-constrained" and one of the used values will have to be different from its computed value. If the direction property of the containing block has the value ltr, the specified value of margin-right is ignored and the value is calculated so as to make the equality true. If the value of direction is rtl, this happens to margin-left instead.
mL, mR の片方だけ不定:
その不定な片方について等式を解いて解決する。 If there is exactly one value specified as auto, its used value follows from the equality.
mL, mR ともに不定:
mL, mR について, mL = mR の下で等式を解いて解決する。 これは、 包含ブロックの左右の辺を基準に要素を横方向に中央寄せにする。 ↓↓
W は不定:
不定な[ mRmL ]は 0 に解決した上で、 W について等式を解いて解決する。 If width is set to auto, any other auto values become 0 and width follows from the resulting equality.↑↑If both margin-left and margin-right are auto, their used values are equal. This horizontally centers the element with respect to the edges of the containing block.

【 見通しを良くするため、 この節では,原文による場合分けを一部 組み替えている。 】

10.3.4. 通常フロー内にあるブロックレベルの置換要素

§ 各種ボックスに対する横幅の計算法, および § 10.3.3 を見よ。 The used value of width is determined as for inline replaced elements. Then the rules for non-replaced block-level elements are applied to determine the margins.

10.3.5. 浮動している置換されない要素

§ 各種ボックスに対する横幅の計算法 を見よ。 If margin-left, or margin-right are computed as auto, their used value is 0.If width is computed as auto, the used value is the "shrink-to-fit" width.Calculation of the shrink-to-fit width is similar to calculating the width of a table cell using the automatic table layout algorithm. Roughly: calculate the preferred width by formatting the content without breaking lines other than where explicit line breaks occur, and also calculate the preferred minimum width, e.g., by trying all possible line breaks. CSS 2 does not define the exact algorithm. Thirdly, find the available width: in this case, this is the width of the containing block minus the used values of margin-left, border-left-width, padding-left, padding-right, border-right-width, margin-right, and the widths of any relevant scroll bars.Then the shrink-to-fit width is: min(max(preferred minimum width, available width), preferred width).

10.3.6. 浮動している置換要素

§ 各種ボックスに対する横幅の計算法 を見よ。 If margin-left or margin-right are computed as auto, their used value is 0. The used value of width is determined as for inline replaced elements.

10.3.7. 絶対的に位置された置換されない要素

【 この節の内容は、 [CSS-POSITION-3]対応する節 に移譲。 】

10.3.8. 絶対的に位置された置換要素

【 この節の内容は、 [CSS-POSITION-3]対応する節 に移譲。 】

10.3.9. 通常フロー内にある置換されない行内ブロック要素

§ 各種ボックスに対する横幅の計算法 を見よ。 If width is auto, the used value is the shrink-to-fit width as for floating elements.A computed value of auto for margin-left or margin-right becomes a used value of 0.

10.3.10. 通常フロー内にある行内ブロック置換要素

§ 各種ボックスに対する横幅の計算法 を見よ。 Exactly as inline replaced elements.

10.X. 置換要素のサイズ法

【 この節(この訳による追加)は、 原文の各所に散らばる類似な記述を集約して整理したものである。 】

置換要素に対する不定な[ WH ]( widthheight の算出値 auto )は, 下の表に従って[ “結果の W” / “結果の H” ]の列で与えられる値に解決される — ここで:

  • nWnHnA ]は、 置換要素の生来な[ 横幅/縦幅/縦横比 ]生来な寸法 — 縦横比は[ 横幅 ÷ 縦幅 ]を表すとする。
  • 表の中の[ WH ]列の “?” は,それが不定であることを表し、 “定” は確定的であることを表す。
  • 同様に,[ nWnHnA ]列の “?” は,置換要素がそれを持たない(不定である)ことを表し、 “定” は持つことを表す。 置換要素がこれらのうち 2 つを持つならば、 残る 1 つも持つことになる (その 2 つから,自動的に導出される)。
W H nW nH nA 結果の W 結果の H
W W ÷ nA
W W ÷ nA
W nH
W 150px
W 150px
H × nA H
H × nA H
300px H
nW H
300px H
nW nH
X X ÷ nA
300px nH
nW 150px
300px 150px

【 いずれにせよ、 生来な縦横比が不定でないならば,それを保つことが趣旨にある (しかしながら, W, H ともに不定でない場合、 この節は適用されず,生来な縦横比も無視されることになる)。 】

ここで:

  • X は、[ 包含ブロックの横幅が,置換要素の横幅に依存しない ]ならば, § 10.3.3 に利用される等式による拘束の下で計算される。 他の場合は 300px。

    CSS 2 においては、 行内レベルの置換要素に対する X は未定義とするが,同様に計算することが示唆される。

  • 結果の[ WH ]に対する値[ “300px” / “150px” ]は、 実際には,[ 横幅 : 縦幅 = 2 : 1 ]の矩形が[ 機器に可用なサイズ, および 300px × 150px の矩形 ]の両者に収まるような,最大なサイズの[ 横幅/縦幅 ]を表す。

10.4. 最小, 最大な横幅: min-width, max-width

名前 min-width
<length> | <percentage>
初期値 0
適用対象 すべての要素 — ただし,[ 行内ボックス, table-row, table-row-group ]は除く。 all elements but non-replaced inline elements, table rows, and row groups
継承 されない
百分率 包含ブロックの横幅を基準にする。 refer to width of containing block
算出値 長さは絶対化される/ 他は指定されたとおり the percentage as specified or the absolute length
正準的順序 文法に従う
名前 max-width
<length> | <percentage> | none
初期値 none
適用対象 min-width と同じ
継承 同上
百分率 同上
算出値 同上
正準的順序 文法に従う

これら 2 つのプロパティにより、 作者は,内容横幅をある範囲に拘束できるようになる。 各種値の意味は: These two properties allow authors to constrain content widths to a certain range. Values have the following meanings:

<length>
固定的な 最小/最大 使用横幅を指定する。 Specifies a fixed minimum or maximum used width.
<percentage>
使用値を決定するための百分率を指定する。 百分率は、 生成されるボックスの包含ブロックの横幅を基準に計算される。 包含ブロックの横幅が負である場合、 使用値は 0 になる。 包含ブロックの横幅が,要素の横幅に依存する場合の結果のレイアウトは、 CSS 2 においては定義されない。 Specifies a percentage for determining the used value. The percentage is calculated with respect to the width of the generated box’s containing block. If the containing block’s width is negative, the used value is zero. If the containing block’s width depends on this element’s width, then the resulting layout is undefined in CSS 2.
none
(この値は max-width のみとり得る。) ボックスの横幅を制限しない。 (Only on max-width) No limit on the width of the box.

min-widthmax-width に対する負な値は、 合法でない。 Negative values for min-width and max-width are illegal.

CSS 2 においては、[ table, inline-table, table-cell, table-column, table-column-group ]に対しては, min-widthmax-width の効果は定義されない。 In CSS 2, the effect of min-width and max-width on tables, inline tables, table cells, table columns, and column groups is undefined.

この 2 つのプロパティが width プロパティの使用値にどう波及するかについては、 次のアルゴリズムで述べられる: The following algorithm describes how the two properties influence the used value of the width property:

  1. 先ず、 § 横幅とマージンの計算法 に従って,仮の使用横幅 W を計算する。 The tentative used width is calculated (without min-width and max-width) following the rules under "Calculating widths and margins" above.
  2. W > max-width の算出値 maxW ]ならば、 width の算出値に maxW を利用する下で,再度 § 横幅とマージンの計算法 を適用する。 If the tentative used width is greater than max-width, the rules above are applied again, but this time using the computed value of max-width as the computed value for width.
  3. [ 結果の横幅 W < min-width の算出値 minW ]ならば、 width の算出値に minW を利用する下で,再度 § 横幅とマージンの計算法 を適用する。 If the resulting width is smaller than min-width, the rules above are applied again, but this time using the value of min-width as the computed value for width.

注記: これらの手続きは、 上のプロパティの本当の算出値には影響しない。 These steps do not affect the real computed values of the above properties.

ただし、 生来な縦横比を伴う置換要素のうち[ width, height ]とも算出値は auto になるものに対しては、 以下に与えるアルゴリズムで決定される: However, for replaced elements with an intrinsic ratio and both width and height specified as auto, the algorithm is as follows:

縦横比を伴うサイズ不定の置換要素に対する最大, 最小サイズの適用法

生来な縦横比を伴う置換要素のうち[ width, height ]とも auto が指定されているものに対しては、[ min-*, max-* ]プロパティは,要素の[ width, height ]の使用値に次に従うように影響する:

  1. まず、 利用される値を定義する:

    max-* に対する値が none の場合、 無限大になる。

    WH は、 通常は,生来な[ 横幅/縦幅 ]になるが、 生来な縦横比のみを伴う場合には,そうなるとは限らない。

    結果の使用値は、 次の式で与えられる:

    • 横幅( width ) = max(X, minW)
    • 縦幅( height ) = max(X ÷ nA, minH)
    • X = min( maxW, maxH × nA, max( W, minW, minH × nA ) )

    【 この式は、 原文の多岐にわたる場合分けを場合分けなしに集約したものである。 概念的には、 元の矩形を, (1) 先ず,サイズ minW × minH の矩形を包含するように,必要なら — 縦横比を保ちながら — 拡大して、 (2) 次に,サイズ maxW × maxH の矩形に収まるように,必要なら — 縦横比を保ちながら — 縮小して、 (3) 最後に,サイズ minW × minH の矩形を包含するように,必要なら(縦横比は無視して)横幅, 縦幅を個別に増やして得られる矩形になる。 】

    Select from the table the resolved height and width values for the appropriate constraint violation. Take the max-width and max-height as max(min, max) so that min ≤ max holds true. In this table w and h stand for the results of the width and height computations ignoring the min-width, min-height, max-width and max-height properties. Normally these are the intrinsic width and height, but they may not be in the case of replaced elements with intrinsic ratios.

    注記: width, height のうち片方には非 auto, もう片方には auto が指定されている場合、 auto にされた方に対し[ min-*max-* ]によるサイズの拘束を適用したときに,拘束され過ぎになり得る。 この仕様は、 ふるまいにおいて明瞭であるが,作者の期待には沿わないかもしれない。 異なる結果を得たいときは、 CSS 3 object-fit プロパティを利用できる。 Note: In cases where an explicit width or height is set and the other dimension is auto, applying a minimum or maximum constraint on the auto side can cause an over-constrained situation. The spec is clear in the behavior but it might not be what the author expects. The CSS3 object-fit property can be used to obtain different results in this situation.

  2. widthheight ]に対する この新たな使用値を算出値とみなす下で,[ § 横幅とマージンの計算法§ 縦幅とマージンの計算法 ]を適用して、 不定なマージンを解決する。 Then apply the rules under "Calculating widths and margins" above, as if width were computed as this value.

10.5. 内容縦幅: height プロパティ

名前 height
<length> | <percentage> | auto
初期値 auto
適用対象 すべての要素 — ただし,[ 行内ボックス, table-column, table-column-group ]は除く。 all elements but non-replaced inline elements, table columns, and column groups
継承 されない
百分率 注釈文を見よ
算出値 絶対長さ/百分率/ auto (ただし, <percentage> は下の注釈文を見よ) the percentage or auto (see prose under <percentage>) or the absolute length
正準的順序 文法に従う

このプロパティは、 ボックスの内容縦幅(内容区画の縦幅)を指定する。 This property specifies the content height of boxes.

このプロパティは、 行内ボックスには適用されない。 代わりに利用される規則については、 § 10.6.1 を見よ。 This property does not apply to non-replaced inline elements. See the section on computing heights and margins for non-replaced inline elements for the rules used instead.

各種値の意味は: Values have the following meanings:

<length>
長さ値を利用して内容区画の縦幅を指定する。 Specifies the height of the content area using a length value.
<percentage>
百分率による縦幅を指定する。 百分率は、 生成されるボックスの包含ブロックの縦幅を基準に計算される。 包含ブロックの縦幅が明示的に指定されていない(すなわち,内容縦幅に依存する), かつ 要素は絶対的に位置されてない場合、 auto に算出される。 根要素に対する百分率による縦幅は、 初期包含ブロックに相対的になる。 Specifies a percentage height. The percentage is calculated with respect to the height of the generated box’s containing block. If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned, the value computes to auto. A percentage height on the root element is relative to the initial containing block.\
注記: 包含ブロックがブロックレベルの要素に基づくような絶対的に位置された要素に対しては、 百分率は,その要素のパディングボックスの縦幅を基準に計算される。 これは、 百分率による縦幅が常に親要素の内容ボックスを基準に計算されていた [CSS1] からの変更である。 Note: For absolutely positioned elements whose containing block is based on a block-level element, the percentage is calculated with respect to the height of the padding box of that element. This is a change from CSS1, where the percentage was always calculated with respect to the content box of the parent element.
auto
縦幅は、 他のプロパティの値に依存する。 以下の各節を見よ。 The height depends on the values of other properties. See the prose below.

注記: 絶対的に位置された要素の包含ブロックの縦幅は,要素自身のサイズから独立であり, そのような要素上の百分率による縦幅は、 常に解決できる。 しかしながら、 文書内の後に来る要素が処理されるまで,縦幅は既知にならないこともある。 Note that the height of the containing block of an absolutely positioned element is independent of the size of the element itself, and thus a percentage height on such an element can always be resolved. However, it may be that the height is not known until elements that come later in the document have been processed.

height に対する負な値は、 合法でない。 Negative values for height are illegal.

例えば,次の規則は、 段落の内容縦幅を 100 ピクセルに設定する: For example, the following rule sets the content height of paragraphs to 100 pixels:

p { height: 100px }

内容の縦幅が 100ピクセル を超過するような段落は、 overflow プロパティに則って過フローすることになる。 Paragraphs of which the height of the contents exceeds 100 pixels will overflow according to the overflow property.

10.6. 縦幅とマージンの計算法

以下の各節では、 関連する各種プロパティの値を次の記号で表す:

これらの値は、 初期時には,各プロパティの算出値に設定されているとする。 この節の目的は、 これらのうち, 不定なauto をとるものを 解決して 使用値を得ることである(拘束され過ぎになる場合も取り扱いつつ)。 For calculating the values of top, margin-top, height, margin-bottom, and bottom a distinction must be made between various kinds of boxes:inline, non-replaced elementsinline, replaced elementsblock-level, non-replaced elements in normal flowblock-level, replaced elements in normal flowfloating, non-replaced elementsfloating, replaced elementsabsolutely positioned, non-replaced elementsabsolutely positioned, replaced elementsinline-block, non-replaced elements in normal flowinline-block, replaced elements in normal flowFor Points 1-6 and 9-10, the used values of top and bottom are determined by the rules in section 9.4.3.

注記: 以下の規則は、 根要素にも,他の要素と同じように適用される。 Note: these rules apply to the root element just as to any other element.

注記: 以下で計算される height の使用値は仮の値であり、 min-height, max-height に依存して,複数回 計算する必要が生じることもある。 § 最小, 最大な縦幅 を見よ。 Note. The used value of height calculated below is a tentative value, and may have to be calculated multiple times, depending on min-height and max-height, see the section Minimum and maximum heights below.

【 原文には,有位置な要素の[ topbottom ]の使用値の計算法も含まれているが、 今や [CSS-POSITION-3] にて定義されるので,和訳は省略する (これらは、 他の要素には適用されない)。 】

10.6.X. 各種ボックスに対する縦幅の計算法

【 この訳では、 各種ボックスに対する縦幅の計算法を,この節の中で一括して与える。 】

  1. 先ず,置換要素に対しては、 不定な H§ 置換要素のサイズ法 に従って解決した上で、 以下を適用する。
  2. 絶対的に位置された要素に対しては、 § 10.6.4 にて与えられる。
  3. 他の要素に対しては:

    1. 不定な[ mTmB ]は :行内ボックスに対しては、縦方向マージンは適用されないので計算されない / 他の要素に対しては、 0 に解決する
    2. 不定な H については、 次の状況を判別する必要がある (置換要素については最初の段で解決済みなので、 この段は関わらない):

      新たなブロック整形文脈を確立する要素

      § ブロック整形文脈の根に対する自動縦幅 にて与えられる。 次に挙げるもの(のうち,他の整形文脈を確立しないもの)が該当する:

      行内レベルの要素に対しては、 それを包含する行ボックスの縦幅を計算するときには,要素のマージンボックスが利用される。

      新たな整形文脈を確立しない,行内レベルの要素(通常フロー内に行内ボックスを生成するもの)
      § 10.6.1 にて与えられる。
      新たな整形文脈を確立しない,ブロックレベルの要素
      行内整形文脈を確立するボックスを生成する,ブロックレベルの要素
      § 10.6.3 にて与えられる — 上の (A) で除外されたものも,ここに含まれる。
      他の整形文脈を確立する要素
      その整形文脈の規則に従う — この文書では定義されない。 CSS 2 においては、 テーブルボックスが該当する。

10.6.1. 行内ボックスを生成する要素

行内ボックスに対しては height は適用されないので、 不定な H も計算されない。 内容区画の縦幅はフォントに基づくべきであるが、 この仕様では,その方法は指定されない。 UA は、 例えば, em-box や, フォントの最大な アセンダ/ディセンダ を利用してもよい (後者の場合、 em-box の上下にはみ出るグリフがあっても, 内容区画の中に収まることを確保するが、 ボックスのサイズがフォントごとにまちまちになる。 前者の場合、 作者は line-height に相対的な背景のスタイル付けを制御できるようになるが、 グリフの一部は,内容区画の外に塗られるようになる。) The height property does not apply. The height of the content area should be based on the font, but this specification does not specify how. A UA may, e.g., use the em-box or the maximum ascender and descender of the font. (The latter would ensure that glyphs with parts above or below the em-box still fall within the content area, but leads to differently sized boxes for different fonts; the former would ensure authors can control background styling relative to the line-height, but leads to glyphs painting outside their content area.)

注記: CSS 3 では,おそらく、[ フォントのどの計量を内容縦幅に利用するか ]を選定するようなプロパティが含められることになる。 Note: level 3 of CSS will probably include a property to select which measure of the font is used for the content height.

行内ボックスの縦方向の[ パディング, ボーダー, マージン ]は、 内容区画の 上端/下端 から開始される — line-height は、 行ボックスの縦幅を計算するときに利用されるだけで,それには関わらない。 The vertical padding, border and margin of an inline, non-replaced box start at the top and bottom of the content area, and has nothing to do with the line-height. But only the line-height is used when calculating the height of the line box.

複数のフォントが利用される場合 (利用されるグリフが,他と異なるフォント内に見出されたときに起こる) の内容区画の縦幅は、 この仕様では定義されない。 しかしながら,縦幅は、 内容区画が,要素内容に利用されるすべてのフォントの[ em-box , または 最大なアセンダと最大なディセンダの和 ]を収めるに十分な高さにすることが示唆される。 これは、 フォントの基底線の整列に依存して,利用される どのフォントサイズよりも大きくなり得ることに注意。 If more than one font is used (this could happen when glyphs are found in different fonts), the height of the content area is not defined by this specification. However, we suggest that the height is chosen such that the content area is just high enough for either (1) the em-boxes, or (2) the maximum ascenders and descenders, of all the fonts in the element. Note that this may be larger than any of the font sizes involved, depending on the baseline alignment of the fonts.

10.6.2. 通常フロー内にある[行内レベル/ブロックレベル/行内ブロック]置換要素/浮動している置換要素

§ 各種ボックスに対する縦幅の計算法 を見よ。 If margin-top, or margin-bottom are auto, their used value is 0.If height and width both have computed values of auto and the element also has an intrinsic height, then that intrinsic height is the used value of height.Otherwise, if height has a computed value of auto, and the element has an intrinsic ratio then the used value of height is: • (used width) / (intrinsic ratio)Otherwise, if height has a computed value of auto, and the element has an intrinsic height, then that intrinsic height is the used value of height.Otherwise, if height has a computed value of auto, but none of the conditions above are met, then the used value of height must be set to the height of the largest rectangle that has a 2:1 ratio, has a height not greater than 150px, and has a width not greater than the device width.

10.6.3. 通常フロー内にあるブロックレベルの置換されない要素

§ 各種ボックスに対する縦幅の計算法 (新たな整形文脈を確立しない場合)も見よ。 This section also applies to block-level non-replaced elements in normal flow when overflow does not compute to visible but has been propagated to the viewport.If margin-top, or margin-bottom are auto, their used value is 0. If height is auto, the height depends on whether the element has any block-level children and whether it has padding or borders:

不定な H は、[ 要素がブロックレベルの子を持つかどうか, および パディングまたはボーダーを持つかどうか ]に依存して、[ 要素が生成するボックス box内容区画の上端辺 ]から[ 次のうち最初に該当するもの ]までの距離に解決する: The element’s height is the distance from its top content edge to the first applicable of the following:

  1. box行内整形文脈を確立している 【すなわち、ブロックレベルの子を持たない】 , かつ 行ボックスを一つは含む場合 :最後の行ボックスの下端辺 the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines
  2. box の子にフロー内にあるものがある場合、 そのような子のうち最後のものを E とするとき:

    1. E の下端マージン m と, box の下端マージンとが相殺されない場合 :mマージン辺m は,場合によっては他と相殺される)
    2. box の上端マージンと下端マージンとが相殺されない場合 :E の下端ボーダー辺
    the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child’s bottom margin does not collapse with the element’s bottom marginthe bottom border edge of the last in-flow child whose top margin doesn’t collapse with the element’s bottom margin
  3. 上に該当するものが無い場合 :H は 0 に解決する zero, otherwise

通常フロー内にある子のみが織り込まれる (すなわち,[ 浮動体絶対的に位置されたボックス ]は無視され、 相対的に位置されたボックスは,オフセットされていないと見なす)。 子ボックスは匿名ブロックボックスの場合もあることに注意。 Only children in the normal flow are taken into account (i.e., floating boxes and absolutely positioned boxes are ignored, and relatively positioned boxes are considered without their offset). Note that the child box may be an anonymous block box.

10.6.4. 絶対的に位置された置換されない要素

【 この節の内容は、 [CSS-POSITION-3]対応する節 に移譲。 】

10.6.5. 絶対的に位置された置換要素

【 この節の内容は、 [CSS-POSITION-3]対応する節 に移譲。 】

10.6.6. 複雑な事例

§ 各種ボックスに対する縦幅の計算法 (新たな整形文脈を確立する場合)を見よ。 This section applies to:Block-level, non-replaced elements in normal flow when overflow does not compute to visible (except if the overflow property’s value has been propagated to the viewport).inline-block, non-replaced elements.Floating, non-replaced elements.If margin-top, or margin-bottom are auto, their used value is 0. If height is auto, the height depends on the element’s descendants per 10.6.7.For inline-block elements, the margin box is used when calculating the height of the line box.

10.6.7. ブロック整形文脈の根に対する auto 縦幅

ブロック整形文脈を確立する要素に対する不定な H は、 以下に従って解決される: In certain cases (see, e.g., sections 10.6.4 and 10.6.6 above), the height of an element that establishes a block formatting context is computed as follows:

要素は行内レベルの子のみを持つ場合【すなわち,ブロックレベルの子を持たない】 If it only has inline-level children,\
縦幅は、[ 最も上端にある行ボックスの上端から, 最も下端にある行ボックスの下端まで ]の距離 the height is the distance between the top of the topmost line box and the bottom of the bottommost line box.
要素はブロックレベルの子を持つ場合 【すなわち,行内レベルの子は匿名なブロックレベルのボックスで包装される】 If it has block-level children,\
縦幅は、 ブロックレベルの子ボックスのマージン辺のうち[ 最も上端にある上端マージン辺から, 最も下端にある下端マージン辺まで ]の距離 the height is the distance between the top margin-edge of the topmost block-level child box and the bottom margin-edge of the bottommost block-level child box.

絶対的に位置された子は 無視され、 相対的に位置されたボックスは オフセットなしと見なされる。 匿名ブロックボックスになる子ボックスもあることに注意。 Absolutely positioned children are ignored, and relatively positioned boxes are considered without their offset. Note that the child box may be an anonymous block box.

加えて, ↓ を満たす要素の子孫がある場合、 縦幅は,それらのマージン辺を含むように増やされる:

例えば、[ 絶対的に位置された子孫/他の浮動体 ]の内側にある浮動体は,織り込まれない。

In addition, if the element has any floating descendants whose bottom margin edge is below the element’s bottom content edge, then the height is increased to include those edges. Only floats that participate in this block formatting context are taken into account, e.g., floats inside absolutely positioned descendants or other floats are not.

10.7. 最小, 最大な縦幅: min-height, max-height

要素の縦幅をある範囲に拘束できると有用になることもある。 次の 2 つのプロパティがこの機能性を提供する: It is sometimes useful to constrain the height of elements to a certain range. Two properties offer this functionality:

名前 min-height
<length> | <percentage>
初期値 0
適用対象 すべての要素 — ただし,[ 行内ボックス, table-column, table-column-group ]は除く。 all elements but non-replaced inline elements, table columns, and column groups
継承 されない
百分率 注釈文を見よ
算出値 百分率は指定されたとおり/ 長さは絶対化される the percentage as specified or the absolute length
正準的順序 文法に従う
名前 max-height
<length> | <percentage> | none
初期値 none
適用対象 min-height と同じ
継承 同上
百分率 同上
算出値 同上
正準的順序 文法に従う

これら 2 つのプロパティにより、 作者は,ボックスの縦幅をある範囲に拘束できるようになる。 各種値の意味は: These two properties allow authors to constrain box heights to a certain range. Values have the following meanings:

<length>
固定的な最小/最大算出縦幅を指定する。 Specifies a fixed minimum or maximum computed height.
<percentage>
使用値を決定するときの百分率を指定する。 百分率は、 生成されるボックスの包含ブロックの縦幅を基準に計算される。 要素の包含ブロックの縦幅が明示的に指定されていない (すなわち、包含ブロックの内容縦幅に依存する), かつ 要素が絶対的に位置されていない場合の百分率値は min-height に対しては 0max-height に対しては none ]に扱われる。 【算出値がこの値とされるわけではなく、以下に述べる縦幅に対する拘束を無にすると見られる。】 Specifies a percentage for determining the used value. The percentage is calculated with respect to the height of the generated box’s containing block. If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned, the percentage value is treated as 0 (for min-height) or none (for max-height).
none
max-height のみがとり得る) ボックスの縦幅は制限されない。 (Only on max-height) No limit on the height of the box.

min-heightmax-height に対する負な値は合法でない。 Negative values for min-height and max-height are illegal.

CSS 2 においては、[ table, inline-table, table-cell, table-column, table-row-group ]に対しては, min-heightmax-height の効果は定義されない。 In CSS 2, the effect of min-height and max-height on tables, inline tables, table cells, table rows, and row groups is undefined.

この 2 つのプロパティが height プロパティの使用値にどう波及するかについては、 次のアルゴリズムで述べられる: The following algorithm describes how the two properties influence the used value of the height property:

  1. 先ず、 § 縦幅とマージンの計算法 に従って,仮の使用縦幅 H を計算する。 The tentative used height is calculated (without min-height and max-height) following the rules under "Calculating heights and margins" above.
  2. H > max-height の算出値 maxH ]ならば、 height の算出値に maxH を利用する下で,再度 § 縦幅とマージンの計算法 を適用する。 If this tentative height is greater than max-height, the rules above are applied again, but this time using the value of max-height as the computed value for height.
  3. [ 結果の縦幅 H < min-height の算出値 minH ]ならば、 height の算出値に minH を利用する下で,再度 § 縦幅とマージンの計算法 を適用する。 If the resulting height is smaller than min-height, the rules above are applied again, but this time using the value of min-height as the computed value for height.

注記: この手続きは、 上の各プロパティの本当の算出値には影響しない。 height の使用値が変化しても、 マージン相殺法に対する効果はない。 § マージンの相殺法における[ min-heightmax-height ]用の規則から特に要求されない限り。 These steps do not affect the real computed values of the above properties. The change of used height has no effect on margin collapsing except as specifically required by rules for min-height or max-height in "Collapsing margins" (8.3.1).

ただし,生来な縦横比を伴う置換要素のうち[ width, height ]とも算出値は auto になるものに対しては、 § 縦横比を伴うサイズ不定の置換要素に対する最大, 最小サイズ に従って,その使用値を見出す。 However, for replaced elements with both width and height computed as auto, use the algorithm under Minimum and maximum widths above to find the used width and height. Then apply the rules under "Computing heights and margins" above, using the resulting width and height as if they were the computed values.

10.8. 行高の計算: line-height, vertical-align プロパティ

§ 行内整形文脈にて述べたように、 UA は,行内レベルのボックスたちを 行ボックスたちを縦方向に堆積してフローさせる。 行高(行ボックスの縦幅)は、 以下に従って決定される: As described in the section on inline formatting contexts, user agents flow inline-level boxes into a vertical stack of line boxes. The height of a line box is determined as follows:

  1. 行ボックス内の行内レベルのボックスの縦幅は: [ 置換要素行内ブロックinline-table ]に対しては、 そのマージンボックスの縦幅になる。 行内ボックスに対しては、 その line-height になる (§ 縦幅とマージンの計算法, § 行アキ行内ボックスの縦幅を見よ。) The height of each inline-level box in the line box is calculated. For replaced elements, inline-block elements, and inline-table elements, this is the height of their margin box; for inline boxes, this is their line-height. (See "Calculating heights and margins" and the height of inline boxes in "Leading and half-leading".)
  2. 行内レベルのボックスたちは、 vertical-align プロパティに則って縦方向に整列される。 それらが[ topbottom ]に整列される場合、 行高(ボックスたちが属する行ボックスの縦幅)を最小化するように整列するものとする。 そのようなボックスたちが十分高い場合、 複数の解法があり得る — CSS 2 は、 行ボックスの基底線の位置決め(すなわち、後述の支柱の位置決め)は定義しない。 The inline-level boxes are aligned vertically according to their vertical-align property.In case they are aligned top or bottom, they must be aligned so as to minimize the line box height. If such boxes are tall enough, there are multiple solutions and CSS 2 does not define the position of the line box’s baseline (i.e., the position of the strut, see below).
  3. 行高は、【同じ行ボックスの中の】 最も上側にあるボックスの上端と, 最も下側にあるボックスの下端との距離である (これには、 下の line-height にて説明される支柱も含まれる)。 The line box height is the distance between the uppermost box top and the lowermost box bottom. (This includes the strut, as explained under line-height below.)

空な行内要素は,空な行内ボックスを生成するが、 これらのボックスにも[ マージン, パディング, ボーダー, 行高 ]は依然としてあるので、 内容を伴う要素と同じく,これらの計算に波及する。 Empty inline elements generate empty inline boxes, but these boxes still have margins, padding, borders and a line height, and thus influence these calculations just like elements with content.

10.8.1. 行アキと半行アキ

CSS においては、 どのフォントも,次の記号で表されるフォント計量を持つものと見做される:

  • A は、 (所与のフォントの所与のサイズに対する)基底線より上側の高さを意味する。
  • D は、 同様に基底線より下側の深さを意味する。 上端から下端までの距離は A + D になる。

TrueType/OpenTypeフォントの A, D を見出す方法を見よ)。 これらは,全体としてのフォントの計量であり、 個々のグリフのアセンダやディセンダに対応させる必要はないことに注意。

CSS assumes that every font has font metrics that specify a characteristic height above the baseline and a depth below it. In this section we use A to mean that height (for a given font at a given size) and D the depth. We also define AD = A + D, the distance from the top to the bottom. (See the note below for how to find A and D for TrueType and OpenType fonts.) Note that these are metrics of the font as a whole and need not correspond to the ascender and descender of any individual glyph.

UA は、 行内ボックス内のグリフたちを, それらに関連する基底線により互いに整列するものとする。 しかる後、 各グリフに対し, A, D を決定する。 同じ要素にて,異なるフォントのグリフが利用されることもあるので、 すべてのグリフが同じ A, D になるとは限らないことに注意。 行内ボックスがグリフを一つも包含しない場合、 要素にて可用な最初のフォントA, D を伴うような, 支柱(横幅 0 の不可視なグリフ)を包含するものと見なされる。 User agent must align the glyphs in a non-replaced inline box to each other by their relevant baselines. Then, for each glyph, determine the A and D. Note that glyphs in a single element may come from different fonts and thus need not all have the same A and D. If the inline box contains no glyphs at all, it is considered to contain a strut (an invisible glyph of zero width) with the A and D of the element’s first available font.

各グリフに対し、 加えられる “行アキ” [ L = line-height ( A + D ) ]が決定される。 L の半分は A の上側に,もう半分は D の下側に加えられ、 基底線のグリフとその行アキによる[ 総高さ A' = A + L ÷ 2 / 総深さ D' = D + L ÷ 2 ]を与える。 Still for each glyph, determine the leading L to add, where L = line-height - AD. Half the leading is added above A and the other half below D, giving the glyph and its leading a total height above the baseline of A' = A + L/2 and a total depth of D' = D + L/2.

注記: L は負にもなり得る。 Note. L may be negative.

行内ボックスの縦幅は,[ すべてのグリフ, それらの上下各側の半行アキを囲い込む ]ので、 正確に line-height に等しくなる。 子要素のボックスは、 この縦幅には波及しない。 The height of the inline box encloses all glyphs and their half-leading on each side and is thus exactly line-height. Boxes of child elements do not influence this height.

置換されない要素の[ マージン / ボーダー / パディング ]は、 行ボックス計算には関与しないが,依然として,行内ボックスの周囲に描画される。 ゆえに、[ line-height により指定された縦幅 ]が[ 要素に包含されるボックスの内容縦幅 ]より小さい場合には、[ パディング/ボーダー ]の背景と色が,連接している行ボックスの中まで “拡幅” され得ることになる。 UA は、 各ボックスを文書順序で描画するべきである。 したがって、 後続の行のボーダーは,先行する行のボーダーやテキストの上に塗られることになる。 Although margins, borders, and padding of non-replaced elements do not enter into the line box calculation, they are still rendered around inline boxes. This means that if the height specified by line-height is less than the content height of contained boxes, backgrounds and colors of padding and borders may "bleed" into adjoining line boxes. User agents should render the boxes in document order. This will cause the borders on subsequent lines to paint over the borders and text of previous lines.

注記: CSS 2 は、 何が行内ボックスの内容区画とされるかについては定義しない ( § 10.6.1 を見よ)。 したがって、 背景やボーダーが描かれる所は,UA により異なることもある。 Note. CSS 2 does not define what the content area of an inline box is (see 10.6.1 above) and thus different UAs may draw the backgrounds and borders in different places.

注記: OpenType/TrueType フォントを利用する実装は、 A, D に対し, (現在の要素のフォントサイズに拡縮した後の)[ フォントの OS/2 テーブルによる計量 “sTypoAscender”, “sTypoDescender” ]を利用することが推奨される。 これらの計量が無い下では、[ HHEA テーブルによる計量 “Ascent”, “Descent” ]が利用されるべきである。 Note. It is recommended that implementations that use OpenType or TrueType fonts use the metrics "sTypoAscender" and "sTypoDescender" from the font’s OS/2 table for A and D (after scaling to the current element’s font size). In the absence of these metrics, the "Ascent" and "Descent" metrics from the HHEA table should be used.

10.8.2. line-height プロパティ

名前 line-height
normal | <number> | <length> | <percentage>
初期値 normal
適用対象 すべての要素 all elements
継承 される
百分率 要素自身のフォントサイズを基準にする。 refer to the font size of the element itself
算出値<length><percentage> ]は絶対化される/ 他は指定されたとおり for <length> and <percentage> the absolute value; otherwise as specified
正準的順序 文法に従う

内容が行内レベルの要素から構成されるような,ブロックコンテナ要素に対しては:

  • line-height は, 要素の中の行ボックスたちの必要最小限な行高(ボックスの縦幅)を指定する。 最小な行高は、 基底線の上側の最小縦幅, 下側の最小深さの和である
  • 各行ボックスは、 支柱 ( strut )と呼ばれる仮想のボックス — 要素の[ font-size, line-height ]プロパティを伴う,横幅 0 の行内ボックス — から開始されたかのようになる (この名前は TeX に由来する)。
On a block container element whose content is composed of inline-level elements, line-height specifies the minimal height of line boxes within the element. The minimum height consists of a minimum height above the baseline and a minimum depth below it, exactly as if each line box starts with a zero-width inline box with the element’s font and line height properties. We call that imaginary box a "strut." (The name is inspired by TeX.).

フォントの基底線の上下側の[ 高さ, 深さ ]は、 フォント内に包含されている計量と見做される (詳細は、 CSS 3 に)。 The height and depth of the font above and below the baseline are assumed to be metrics that are contained in the font. (For more details, see CSS level 3.)

行内ボックスに対しては、 line-height は,行高の計算に利用される縦幅を指定する。 On a non-replaced inline element, line-height specifies the height that is used in the calculation of the line box height.

このプロパティに対する各種 値の意味は: Values for this property have the following meanings:

normal
UA は、 使用値を要素のフォントに基づく “適度な” 値に設定する。 値は <number> と同じ意味を持つ。 normal に推奨される使用値は、 1.0 以上 1.2 以下である。 Tells user agents to set the used value to a "reasonable" value based on the font of the element. The value has the same meaning as <number>. We recommend a used value for normal between 1.0 to 1.2. The computed value is normal.
<length>
指定された長さは、 行高の計算に利用される。 The specified length is used in the calculation of the line box height. Negative values are illegal.
<number>
プロパティの使用値は、 この数値と要素のフォントサイズとの積になる。 The used value of the property is this number multiplied by the element’s font size. Negative values are illegal. The computed value is the same as the specified value.
<percentage>
プロパティの算出値は、 この百分率値と要素のフォントサイズとの積になる。 The computed value of the property is this percentage multiplied by the element’s computed font size. Negative values are illegal.

line-height に対する負な値は合法でない。

下の例の 3 つの規則による結果の行高は、 どれも同じになる: The three rules in the example below have the same resultant line height:

div {
  line-height: 1.2;    /* 実数( <number> */
  font-size: 10pt
}
div {
  line-height: 1.2em;  /* 長さ( <length> */
  font-size: 10pt
}
div {
  line-height: 120%;   /* 百分率( <percentage> */
  font-size: 10pt
}

要素が,複数のフォントで描画されるテキストを包含する場合、 UA は,[ line-height 用の値 normal ]を最大なフォントサイズに則って決定してもよい。 When an element contains text that is rendered in more than one font, user agents may determine the normal line-height value according to the largest font size.

注記: ブロックコンテナボックス内のすべての行内ボックスにおいて[ ( normal 以外の) line-height 値は互いに同じ ]かつ[ 利用している最初に可用なフォントも互いに同じ ](かつ,コンテナ内には 置換要素, 行内ブロック, 等も無い)場合、 上述により, 連続する行たちの互いの基底線は正確に line-height ずつ離れるようになる。 これは、 例えばテーブルなど,column たちを — それらの内容テキストに,column ごとに異なるフォントが利用されるときでも — 互いに整列させる必要があるときに,重要になる。 Note. When there is only one value of line-height (other than normal) for all inline boxes in a block container box and they all use the same first available font (and there are no replaced elements, inline-block elements, etc.), the above will ensure that baselines of successive lines are exactly line-height apart. This is important when columns of text in different fonts have to be aligned, for example in a table.

10.8.3. vertical-align プロパティ

名前 vertical-align
baseline | sub | super | top | text-top | middle | bottom | text-bottom | <percentage> | <length>
初期値 baseline
適用対象 行内レベルの要素 / table-cell 要素 inline-level and table-cell elements
継承 されない
百分率 要素自身の line-height を基準にする。 refer to the line-height of the element itself
算出値<length><percentage> ]は絶対化される/ 他は指定されたとおり for <percentage> and <length> the absolute length, otherwise as specified
正準的順序 文法に従う

このプロパティは、 行内レベルの要素により生成されるボックスに対する,[ 行ボックスの内側における縦方向の位置決め ]に影響する。 This property affects the vertical positioning inside a line box of the boxes generated by an inline-level element.

注記: このプロパティの値は、 テーブルの文脈では異なる意味になる。 詳細は、 § テーブル縦幅のアルゴリズム に諮られたし。 Note. Values of this property have different meanings in the context of tables. Please consult the section on table height algorithms for details.

以下に定義される各種 値は、 親行内要素, および[ 親ブロックコンテナ要素の支柱 ]に関してのみ意味を持つ。 The following values only have meaning with respect to a parent inline element, or to the strut of a parent block container element.

以下の定義において,整列に利用されるボックスは、 行内ボックスに対しては,縦幅が line-height にされた (ボックスのグリフと各側の半行アキを包含している)ボックスであり、 他のすべての要素に対しては,そのマージンボックスである。 In the following definitions, for inline non-replaced elements, the box used for alignment is the box whose height is the line-height (containing the box’s glyphs and the half-leading on each side, see above). For all other elements, the box used for alignment is the margin box.

baseline
ボックスの基底線を,親ボックスの基底線に整列する。 基底線を持たないボックスに対しては、 下端マージン辺を親の基底線に整列する。 Align the baseline of the box with the baseline of the parent box. If the box does not have a baseline, align the bottom margin edge with the parent’s baseline.
middle
ボックスの縦方向の中点を,親ボックスの基底線から親の x-height の半分だけ上方の所に整列する。 Align the vertical midpoint of the box with the baseline of the parent box plus half the x-height of the parent.
sub
ボックスの基底線を,親のボックスの下付き文字に対する適正な位置まで下げる (この値は、 要素のテキストのフォントサイズに効果を及ぼすことはない)。 Lower the baseline of the box to the proper position for subscripts of the parent’s box. (This value has no effect on the font size of the element’s text.)
super
ボックスの基底線を,親のボックスの上付き文字に対する適正な位置まで上げる (この値は、 要素のテキストのフォントサイズに効果を及ぼすことはない)。 Raise the baseline of the box to the proper position for superscripts of the parent’s box. (This value has no effect on the font size of the element’s text.)
text-top
ボックスの上端を,親の内容区画の上端(§ 10.6.1 を見よ)に整列する。 Align the top of the box with the top of the parent’s content area (see 10.6.1).
text-bottom
ボックスの下端を,親の内容区画の下端(§ 10.6.1 を見よ)に整列する。 Align the bottom of the box with the bottom of the parent’s content area (see 10.6.1).
<percentage>
ボックスを,この距離( line-height 値の百分率)だけ上げる(正な値)/下げる(負な値)。 値 0%baseline と同じ意味になる。 Raise (positive value) or lower (negative value) the box by this distance (a percentage of the line-height value). The value 0% means the same as baseline.
<length>
ボックスを,この距離だけ上げる(正な値)/下げる(負な値)。 値 0pxbaseline と同じ意味になる。 Raise (positive value) or lower (negative value) the box by this distance. The value 0cm means the same as baseline.

以下に定義される各種 値は、 要素を行ボックスに相対的に整列する。 要素の子は,要素に相対的に整列されることもあるので (したがって子孫も同様になる)、 これらの値は,整列済み下位ツリーの限界域を利用する。 行内要素の 整列済み下位ツリー は、 その要素, および そのすべての子行内要素のうち[ vertical-align の算出値が topbottom でない ]ものの整列済み下位ツリーを包含する。 整列済み下位ツリーの上端(下端)は、 その下位ツリー内のボックスのうち,最も高い上端(下端)である。 The following values align the element relative to the line box. Since the element may have children aligned relative to it (which in turn may have descendants aligned relative to them), these values use the bounds of the aligned subtree. The aligned subtree of an inline element contains that element and the aligned subtrees of all children inline elements whose computed vertical-align value is not top or bottom. The top of the aligned subtree is the highest of the tops of the boxes in the subtree, and the bottom is analogous.

top
整列済み下位ツリーの上端を,行ボックスの上端に整列する。 Align the top of the aligned subtree with the top of the line box.
bottom
整列済み下位ツリーの下端を,行ボックスの下端に整列する。 Align the bottom of the aligned subtree with the bottom of the line box.

inline-table基底線は、 テーブルの最初の row の基底線とする。 The baseline of an inline-table is the baseline of the first row of the table.

行内ブロック B基底線は、[ Boverflow プロパティの算出値 visible ]かつ[ B 内にフロー内にある行ボックスはある ]ならば,それらの行ボックスのうち最後のものの基底線とする。 他の場合は B の下端マージン辺とする。 The baseline of an inline-block is the baseline of its last line box in the normal flow, unless it has either no in-flow line boxes or if its overflow property has a computed value other than visible, in which case the baseline is the bottom margin edge.