Closed Bug 1813536 Opened 4 months ago Closed 4 months ago

Inconsistent computed-style serialization of line-height vs font shorthand


(Core :: CSS Parsing and Computation, defect)




111 Branch
Tracking Status
firefox111 --- fixed


(Reporter: jfkthame, Assigned: jfkthame)




(1 file)

This Firefox behavior seems a little odd to me:

> = "bold 10px / 1.5 serif"
< "bold 10px / 1.5 serif"
> window.getComputedStyle(document.body).font
< "700 10px / 1.5 serif"
> window.getComputedStyle(document.body).lineHeight
< "15px"

Note that the line-height value, specified in the shorthand as 1.5, has been serialized as 1.5 in the font shorthand of the computed style, but as 15px in the longhand line-height property.

In contrast, Chrome serializes it as 15px in both the shorthand and longhand, which is at least consistent.

(Safari also serializes the line height as 15px in both cases, although it has other issues with the shorthand...)

AFAICS from the CSS2 spec for line-height, the computed value is supposed to be "for <length> and <percentage> the absolute value; otherwise as specified", which would seem to imply that 1.5 would be the expected computed value; but the only place I see this is in the Firefox version of the shorthand; everywhere else, it is resolved to the absolute value 15px.

So maybe that spec is obsolete and we should just converge on using the absolute value? The current inconsistency seems undesirable.

(And presumably the spec for line-height should be updated and moved to a newer spec, but currently everything seems to refer back to CSS2.)

Severity: -- → S3

This makes the serialization of the 'font' shorthand on computed style return the line-height
as an absolute length rather than a number (font-size multiplier), which is consistent with
what the line-height longhand already returns, and with other browsers.

(See also

Assignee: nobody → jfkthame
Attachment #9315360 - Attachment description: Bug 1813536 - Resolve <number> to <length> for computed line-height. r=#firefox-style-system-reviewers → Bug 1813536 - Resolve <number> to <length> in ToResolvedValue for line-height. r=#firefox-style-system-reviewers
See Also: → 1814626
Pushed by
Resolve <number> to <length> in ToResolvedValue for line-height. r=emilio
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch
You need to log in before you can comment on or make changes to this bug.