Re: [csswg-drafts] [css-box] Suggestion: Add "of <property>" syntax for percentage values of padding and margin properties (#6814)

@Loirooriol Yes, the containing block is by definition a rectangle, and it can be the content box or padding box of an element, the viewport, or even the bounding box of two differnt padding boxes of inline elements. Therefore, if we were only interested in the demensions of that rectangle, it would be the best to have new measures for that. Maybe, it would be a good idea to name them `cbh`, `cbw`, `cbi`, `cbb`, `cbmin`, and `cbmax` in accordance with the `cqh`, `cqw`, `cqi`, `cqb`, `cqmin`, and `cqmax` query container relative lengths of [css-contain-3](https://drafts.csswg.org/css-contain-3/#container-query-length). The shortcut cb means here containing block. I didn't know about #1645 but I don't like the measure names suggested there. They are too generic.
BTW, concerning the bounding box of two differnt padding boxes of inline elements [item 4.1. of the definition of containing block in CSS2.1](https://www.w3.org/TR/CSS2/visudet.html#containing-block-details), I have made a few tests which showed that Firefox and Chrome have different options conerning the dimenstions of the containing block.

Concerning the `inherit()` funcction, my understanding is that it only refers to parent element properties. In that case, `inherit()` does something diffenent than my suggested `of <property>` semantics. I am not nailed to the syntax which I suggested, and an alternative would be to also use a function like `cb(<property>)` such that one can write `calc(0.1 * cb(height))` in accordance with the `inherit()` function but `10% of height` is shorter. The disadvantage of the latter is that it is not obvious to which element `height` is related. An alternative would be to use the syntax `10% of cb(height)`.

- If the containing block does not refer to an element, and also not to the viewport, a rule using `of <property>` should be ignored. 
- If the containing block refers to the viewport, the properties `height` and `width` make sense and the viewport height and width should be used. All properties concerning `padding` and `margin` would return a length of 0, as the viewport can be interpreted as having a `margin` and `padding` of size 0. If other properties are used, the complete rule can be ignored. 
- If the containing block refers to an element, `of <property>` should return the same as `inherit()` but refering to the containing block element and not the parent element.

So, `of width` and `of height` refer to the `width` and `height` of the element or the viewport but not to the `width` and `height` of the containing block. Measures should be used in the latter case.

The ability to refer to arbitrary properties of the containing block may be unnecessary or unwanted for some people but it opens up more flexibility for the author of stylesheets, and maybe some new ideas concerning the usage open up new ways for layouts or special designs which were not possible with CSS today Of course, having new measures for the containing block is a first step in that direction.

-- 
GitHub Notification of comment by RolandHeinze
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6814#issuecomment-970889932 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 17 November 2021 00:05:13 UTC