Open Bug 1686513 Opened 3 years ago Updated 3 years ago

[css-pseudo] ::first-line and line-height

Categories

(Core :: Layout: Block and Inline, defect)

defect

Tracking

()

People

(Reporter: mozilla-apprentice, Unassigned)

References

Details

A resolution was made for csswg-drafts/#2282.

[css-pseudo] ::first-line and line-height

  • RESOLVED: Align with chromium behavior for ::first-line and line-height

Discussion.

Testcase from the github issue

<!DOCTYPE html>
<style>
p { border: solid; width: 10em; font-size: 24px; line-height: 36px; }
p:first-line {  background: orange; font-weight: bold; line-height: 12px; font-size: 12px; }
</style>

<p class='container'>This is a test paragraph so let's make more text.

EXPECTED RESULTS is that the line-height:12px should establish the actual height of that first line (e.g. the orange-background chunk should be snapped up to be flush with the black border).

ACTUAL RESULTS is that we have the orange-background chunk vertically-centered in the 36px-tall-line that the block gives ot it.

Here's an "anti-reference-case" where I've wrapped the first line of text (the first line on my system / with my fonts at least) in a span, and I've given the span the same styling as in the original testcase. On my system, the original testcase renders like this, but the CSSWG resolution says it should not.

Essentially, I think we render ::first-line as if it were an inline-level element that just-so-happens to fill the block's entire first line. line-height on an inline element doesn't actually control the height of the line that it's participating in; but in this special case for ::first-line, the CSSWG now resolved that it should.

See Also: → 1068856
You need to log in before you can comment on or make changes to this bug.