Skip to content

[css-tables] Spec should probably be clearer about how, and whether, inheritance happens for table anonymous boxes #1059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bzbarsky opened this issue Feb 23, 2017 · 9 comments

Comments

@bzbarsky
Copy link

Consider this testcase:

<div style="border-spacing: 100px">
  <span style="display: table-cell">One</span>
  <span style="display: table-cell">Two</span>
</div>

What should the rendering look like and why? Per https://drafts.csswg.org/css-tables-3/#fixup-algorithm or https://www.w3.org/TR/CSS21/tables.html#anonymous-boxes we generate an anonymous table box here, but does it inherit the border-spacing value from the div? Is that even a meaningful thing to say, given that inheritance happens on elements, not boxes, and styles are attached to elements, not boxes, as far as I can tell?

Similar for various inherited properties that can affect anonymous table cells (e.g. text-indent).

@fantasai @tabatkins @FremyCompany

@FremyCompany FremyCompany self-assigned this Feb 24, 2017
@FremyCompany
Copy link
Contributor

Good point. I would assume so, like all generated content they get their style from their parent element. I didn't write a test case though so I don't know how interoperable that is.

@bzbarsky
Copy link
Author

Fwiw, in Gecko's implementation they get it from their parent box, which may have the same effect.

I've been trying to figure out whether this is even observable for row-groups, rows, columns, and column-groups. It's definitely observable for cells and tables.

@FremyCompany
Copy link
Contributor

I am not sure we need any spec text though. CSS Cascade mentions that pseudo-elements inherit their style based on the fictional markup representation where they would be actual elements. The table spec defines that sequence via the fixup rules so the inheritance of properties shouldn't need any more clarification.

I can add some more text if people still feel it is a good idea but adding text is like adding code, it create maintenance burden. Is i worth it?

@FremyCompany
Copy link
Contributor

The real question is what you need to do for elements. What do we do for inheritance of properties like "border" on the span if it had "border:inherit":

  • do we inherit from the element
  • or from the generated content.

Depending on what we do, this might or might not need some clarification as it overrules what css-cascade says. I'll write some tests to be sure what each browser does.

@FremyCompany
Copy link
Contributor

https://jsfiddle.net/1wLo3zo7/
Edge, Firefox and Chrome do not take the generated row into consideration. So I think what css-cascade already says to do. I don't know if there is a way to know whether the fact the nested pseudo-elements should inherit their style from each other or all inherit from the parent element, but I don't think so since you cannot assign them any custom style, so only properties that inherit will inherit, and that will continue all the way down to the next element.

If you can think of something, let me know. I wondered if the new currentColor behavior might do something but since color inherits I don't think so.

@bzbarsky
Copy link
Author

CSS Cascade mentions that pseudo-elements inherit their style based on the fictional markup representation

Yes, but various anon boxes are not pseudo-elements. (And note that pseudo-elements may have style but no box, even; they're just a totally distinct concept.)

or from the generated content.

There is no "generated content" here. In any case, this part is well-specified: inheritance happens on the element tree, and anon boxes do not contribute to that tree in any way. So they don't affect inheritance of elements.

I think we all agree on the behavior. And that it's not observable whether you inherit from your "parent" or the nearest "ancestor element". But the spec doesn't even have a concept of style for these boxes at the moment!

(Note that I think ruby has all the same issues, for the same reasons.)

@FremyCompany
Copy link
Contributor

Ok no reason no to make this explicit then, I'll do it. Is this slightly improved version of the text used for "missing cells fixup" ok to you? (pretend I edit this to apply to all generated boxes not just missing cells)

Beside their display type, those anonymous boxes do not receive any specific or default styling, except where otherwise mentioned by this specification (meaning their background is “transparent”, their padding is “0px” and their border is “none” by default); properties who inherit unless directly assigned get their value from the parent element of the box.

@bzbarsky
Copy link
Author

s/who inherit/which inherit/.

With that, looks good, I think.

@FremyCompany
Copy link
Contributor

Don't assume the gender of my properties :D
Ok, that will be it then.

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

No branches or pull requests

2 participants