W3C home > Mailing lists > Public > public-css-archive@w3.org > March 2017

Re: [csswg-drafts] [css-cascade][css-selectors][css-pseudo-elements] How does 'inherit' keyword behave in a child of ::first-line?

From: Loirooriol via GitHub <sysbot+gh@w3.org>
Date: Sun, 19 Mar 2017 17:33:19 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-287632742-1489944797-sysbot+gh@w3.org>
Thanks for the clarifications. Now I will try to be more precise.

Suppose we have

```html
<div>
  <span>ABCDEFGHIJKLMNOPQR<br />STUVWXYZ</span>
</div>
```

If I understand properly, I think you say it becomes somewhat like this:

```html
<div>
  <span>
    <div::first-line>ABCDEFGHIJKLMNOPQR<br /></div::first-line>
    STUVWXYZ
  </span>
</div>
```

(not sure where to put the `<br />`, but that's not relevant)

Then I agree that using `inherit` on the `span` just makes it inherit from the `div`, but that can be overridden by `div::first-line` on the text run in the first line.

However, it doesn't seem to be the case. Try

```css
div {
  color: red;
}
span {
  color: green;
}
div::first-line {
  color: blue;
}
```

All Firefox, Edge and Chrome paint the text with green color, even the text run in the first line. This means the `span` is farther inward than `div::first-line`, so the latter cannot override the former.

Moreover, [Finding the First Formatted Line](https://drafts.csswg.org/css-pseudo-4/#first-text-line) says

> A user agent must act as if the fictional start tags of a ::first-line pseudo-element were nested just inside the innermost enclosing block-level element.

The `span` is not block-level, so I think the tree should instead become like this:

```html
<div>
  <div::first-line>
    <span::fragment-1>ABCDEFGHIJKLMNOPQR<br /></span::part-1>
  </div::first-line>
  <span::fragment-2>STUVWXYZ</span::part-2>
</div>
```

And then, according to [Inheritance and the ::first-line Pseudo-element](https://drafts.csswg.org/css-pseudo-4/#first-line-inheritance),

> the portion of a child element that occurs on the first line only inherits properties applicable to the ::first-line pseudo-element from the ::first-line pseudo-element.

Now this portion in the first line is not only a text run, but a fragment of the span. So that fragment `span::part-1` should inherit from `div::first-line`. The other fragments of the span shouldn't.

Maybe I'm being obtuse, but I don't find the spec much clear, and implementations don't match, so I think the spec should be clarified.

-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1097#issuecomment-287632742 using your GitHub account
Received on Sunday, 19 March 2017 17:33:25 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:09 UTC