Skip to content

[css-display] Element styles should only be assigned to the principal box by default #1702

Closed

Description

@Loirooriol

CSS Display says

Boxes are assigned the same styles as their generating element, unless otherwise indicated.

In my opinion this is a bad default. In fact there is no case in which an element generates multiple boxes and the styles are assigned to all of them. Currently I think only the following cases (*) generate multiple boxes:

  • display: block ruby generates a principal block box which contains an additionally-generated ruby container. As specified in CSS Ruby, the element styles are only assigned to the principal box. The ruby container inherits from the principal box (i.e. through the box tree parentage).

  • A table inner display type generates a principal block container which contains an additionally-generated table box. Some properties are assigned to the principal box and some to the table box (this is a mess), but as far as I know no property is assigned to both.

  • The list-item keyword generates an additional marker box. In fact I'm opposed to this case, I think the marker box should not be generated by the element, instead it should be a principal box generated by the ::marker pseudo-element originated by the element, but this is not what CSS Display says now. Anyways, according to CSS Pseudo, the element styles are not assigned to the marker box.

I think the block ruby behavior would be a much better default, that is:

  • The principal box (if any) is assigned the same styles as their generating element, unless otherwise indicated.
  • Additionally-generated boxes and anonymous boxes inherit through their box tree parentage, unless otherwise indicated.

(*) There is also the case of inline elements with a block-level descendant, which should be clarified in #1604.

Activity

  1. tabatkins commented on Mar 19, 2018

    @tabatkins
    Member

    As part of fixing #1643 in b2d484c, we ended up tightening up the language here too:

    A box is assigned the same styles as its generating [=CSS/element=], unless otherwise indicated.
    In general, inherited properties are assigned to the principal box,
    and then inherit through the box tree
    to any other boxes generated by the same element.
    Non-inherited properties default to applying to the principal box,
    but when the element generates multiple boxes,
    are sometimes defined to apply to a different box:
    for example, the 'border' properties applied to a table element
    are applied to its table grid box,
    not to its principal table wrapper box

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions