skip to Main Content

It is said that everything in CSS is a box, but also the text?

If possible also give me official specifications for consultation.

Some properties are for inline content, so I want to know what type of content the text is.

For example:
https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align

The vertical-align CSS property sets vertical alignment of an inline,
inline-block or table-cell box.

2

Answers


  1. Everything is a box in css. It’s the way the box reacts that is to be set with the display property.

    https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/The_box_model

    Login or Signup to reply.
  2. CSS 2 described Text as always being contained in an inline box, an anonymous one if necessary.

    In a document with HTML markup like this:

    <p>Some <em>emphasized</em> text</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.

    However, CSS3 Display describes things differently. It says that text runs are not boxes, but a different kind of object in the box tree.:

    CSS takes a source document organized as a tree of elements (which can contain a mix of other elements and text nodes) and text nodes (which can contain text), …

    … it generates an intermediary structure, the box tree, which represents the formatting structure of the rendered document. Each box in the box tree represents its corresponding element (or pseudo-element) in space and/or time on the canvas, while each text run in the box tree likewise represents the contents of its corresponding text nodes.

    It should be noted that in the CSS3 scheme, text is inline content, even though it is not a box.

    The precise details of how inline boxes and text runs are laid out can be found in the Inline Layout Model. Note in particular that all the inline boxes and text runs in a block container are wrapped in a single inline box called the root inline box.

    The description of vertical alignment is given in Transverse Box Alignment: the vertical-align property

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search