diff --git a/files/en-us/web/css/visual_formatting_model/index.md b/files/en-us/web/css/visual_formatting_model/index.md index 76ebc1475a80343..1654b2bda45882d 100644 --- a/files/en-us/web/css/visual_formatting_model/index.md +++ b/files/en-us/web/css/visual_formatting_model/index.md @@ -48,11 +48,55 @@ Some elements may generate additional boxes in addition to the principal box, fo An **anonymous box** is created when there is not an HTML element to use for the box. This situation happens when, for example, you declare `display: flex` on a parent element, and directly inside there is a run of text not contained in another element. In order to fix the box tree, an anonymous box is created around that run of text. It will then behave as a flex item, however, it cannot be targeted and styled like a regular box because there is no element to target. -{{EmbedGHLiveSample("css-examples/visual-formatting/anonymous-flex.html", '100%', 720)}} +```html live-sample___anonymous-flex +
I am in the paragraph
+ I am wrapped in an anonymous box. +` element containing part of the text. -{{EmbedGHLiveSample("css-examples/visual-formatting/anonymous-block.html", '100%', 720)}} +```html live-sample___anonymous-block +
I am in the paragraph
+ I am wrapped in an anonymous box. +`, which generates a box, and then another anonymous box. @@ -68,7 +112,34 @@ Other formatting contexts also create anonymous boxes. [Grid layout](/en-US/docs In the following example, the line boxes following the floated `
+ This text is following the float, the line boxes are shortened to make room + for the float but the box of the element still takes position in normal flow. +
+``` + +```css live-sample___line-boxes +body { + font: 1.2em sans-serif; + margin: 20px; +} + +.float { + float: left; + width: 150px; + height: 150px; + background-color: rebeccapurple; + margin: 20px; +} + +.following { + background-color: #ccc; +} +``` + +{{EmbedLiveSample("line-boxes", "", "250px")}} ## Positioning schemes and in-flow and out-of-flow elements @@ -118,9 +189,47 @@ Elements either participate in the formatting context of their containing block **Independent formatting contexts** contain floats, and margins do not collapse across formatting context boundaries. Therefore, creating a new block formatting context can ensure that floats and margins remain inside a box. To do this, add `display: flow-root` to the box on which you wish to create a new [block formatting context](/en-US/docs/Web/CSS/CSS_display/Block_formatting_context). -The following example shows the effect of `display: flow-root`. The box with the black background appears to wrap around the floated item and text. If you remove `display: flow-root` from the editable CSS the floated item will poke out of the bottom of the box as it is no longer contained. - -{{EmbedGHLiveSample("css-examples/display/multi-keyword/block-flow-root.html", '100%', 720)}} +The following example shows the effect of `display: flow-root`. The box with the black background appears to wrap around the floated item and text. If you remove `display: flow-root`, the floated item will poke out of the bottom of the box as it is no longer contained. + +```html live-sample___block-flow-root +Text following the float.
+