Skip to content

[css-pseudo][css-tables-3] Should the first line of a caption be the first line of ancestors? #1192

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

Open
Loirooriol opened this issue Apr 9, 2017 · 2 comments
Labels
css-tables-3 Current Work

Comments

@Loirooriol
Copy link
Contributor

The ::first-line of a block container is supposed to be nested inside the innermost enclosing block box.

CSS Pseudo only excludes

The first line of a table-cell or inline-block cannot be the first formatted line of an ancestor element.

presumably because in CSS 2.1 these were the only block containers that do not participate in a BFC. (Now that we have others, like flex items and grid items, I think the spec should be generalized, see #1174)

But there is another interesting kind of block container: table-caption. The table caption is inside the table wrapper box, which according to CSS 2.1 and CSS Tables 3,

The table wrapper box establishes a block formatting context.

So table-caption is in fact a block container which participates in a BFC, and thus it seems reasonable that CSS 2.1 did not exclude table-caption for ::first-line propagation.

However, the two implementations which nest ::first-line inside inner blocks (Chrome and Edge) do not do this for table-caption.

Consider this example: https://jsfiddle.net/Lwf9h6Lm/

div::first-line { color: red }
span { display: table-caption; color: green }
<div><span>Foo</span></div>

Foo is green on both Chrome and Edge, unaffected by div::first-line.

In fact I think a table wrapper box should establish a table formatting context, and thus the table-caption would participate in that TFC instead of in a BFC (see #1189). Then Foo would be expected to be green.

But if table-caption remains block-level, what should happen with ::first-line? Should browsers change in order to make Foo be red, or should table-caption be added as an exception for ::first-line, to let Foo remain green? And if div::first-line is expected to be nested inside the table-caption, should this still be the case with caption-side:bottom?

@FremyCompany
Copy link
Contributor

http://wptest.center/#/v9wmh0 is I think easier to understand the issue.

<div><table><caption>Abc</caption></table></div>
div::first-line {
    color: red;
}

You are totally right that if we read the spec like it was written this should work and Abc should be red, but is black in all browsers.

I will repeat myself again and claim we should remove the table wrapper box concept, and have the captions be part of the table formatting context, and everything would match implementations and be sane again.

I am ready to keep repeating this every single time anyone mentions how broken the table wrapper box is, if necessary. So please keep the bugs coming :-)

@fantasai
Copy link
Collaborator

fantasai commented Dec 31, 2020

Edited into css-pseudo-4 in 7138498 to be consistent with implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-tables-3 Current Work
Projects
None yet
Development

No branches or pull requests

3 participants