Bug 169610 - [CSS 2.1 Conformance] font shorthand and inherit incorrectly parsed
Summary: [CSS 2.1 Conformance] font shorthand and inherit incorrectly parsed
Alias: None
Product: konqueror
Classification: Applications
Component: khtml renderer (show other bugs)
Version: 4.7.3
Platform: Ubuntu All
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
Keywords: reproducible, testcase
Depends on:
Reported: 2008-08-22 20:53 UTC by Gérard Talbot (no longer involved)
Modified: 2014-06-13 17:29 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.13.2


Note You need to log in before you can comment on or make changes to this bug.
Description Gérard Talbot (no longer involved) 2008-08-22 20:53:44 UTC
Version:            (using KDE 4.1.0)
Compiler:          cc 
OS:                Linux
Installed from:    Debian stable Packages

Bug entry:

  h1 {font-size: 32px;}

  h1 {font: 96px inherit;}

  <h1>This text should be using a  font-size of 32px and not a font-size of 96px.</h1>

CSS validator reports that the 2nd rule has a Parse error, should be rejected; therefore only 
h1 {font-size: 32px;}
should be accepted and rendered.


Regards, Gérard
Comment 1 Gérard Talbot (no longer involved) 2008-08-23 03:26:10 UTC
Also reported :
Comment 2 Maksim Orlovich 2008-08-23 17:25:48 UTC
Hi... I am a bit confused here (but I am not an expert in CSS parsing): 
isn't 'inherit' a valid value for fant-family?
Comment 3 Gérard Talbot (no longer involved) 2008-08-23 22:06:22 UTC
> isn't 'inherit' a valid value for fant-family?

Hello Maksin,

Yes, inherit is a correct and valid value for font-family:

h1 {font-family: inherit;}

is clear, without ambiguity or source of interpretation. But when the CSS parser meets

h1 {font: 96px inherit;}

the CSS parser has no way to know for sure which other font subproperty is actually explicitly being inherited. On the other hand, 

h1 {font: inherit;}

is clear because it applies to all font subproperties (*) and it meets, honors the font shorthand syntax.

The font shorthand can take several font subproperties. The problem for the CSS parser is that it wouldn't be able to figure out which font subproperty. Imagine this situation:

h1 {font: inherit inherit;}

Which pair of font sub-properties have now inherited from its parent? font-size and font-family? font-weight and font-family? font-size and font-style? font-variant and font-style?

The CSS 2.1 spec. is a bit implicit, equivocal on this issue. All the 15.8 section had to say explicitly is that inherit keyword has to apply to all font subproperties when it is involved, used for the font shorthand. Just like it is said for system font reserved keywords:

"System fonts may only be set as a whole; that is, the font family, size, weight, style, etc. are all set at the same time."

It does however states in its syntax that inherit must occur only once. And that is what the CSS validator message is about:

"Value Error : font  Too many values or values are not recognized :  96px inherit "

One last thing. The last paragraph of section 15.8 says:
"the 'font' shorthand property resets any [sub]property not explicitly given a value to its initial value".
Comment 4 Gérard Talbot (no longer involved) 2008-08-23 22:13:44 UTC
> inherit must occur only once.

[ [ <'font-style'> || <'font-variant'> || <'font-weight'> ]? <'font-size'> [ /
<'line-height'> ]? <'font-family'> ] | caption | icon | menu | message-box |
small-caption | status-bar | inherit

"A bar (|) separates two or more alternatives: exactly one of them must occur."
Comment 5 Gérard Talbot (no longer involved) 2008-08-23 22:32:09 UTC
> Hello Maksin,

Sorry! Maksim :)
Comment 6 Gérard Talbot (no longer involved) 2008-11-15 19:04:17 UTC
consider the declaration
font: inherit 100% Arial;
Does 'inherit' set font-style, or font-variant, or font-weight? They are
allowed in any order, and they are all optional, so which one is it?

coming from
Newsgroup: comp.infosystems.www.authoring.stylesheets
Date: Mon, Nov 24 2003
Subject: font-family: inherit -- does not work with shorthand?
Comment 7 Gérard Talbot (no longer involved) 2009-05-02 20:02:38 UTC
From CSS 2.1, Candidate Recommendation 23 April 2009, Appendix C. Changes

C.3.1 Shorthand properties

Shorthand properties take a list of subproperty values or the value 'inherit'. One cannot mix 'inherit' with other subproperty values as it would not be possible to specify the subproperty to which 'inherit' applied. The definitions of a number of shorthand properties did not enforce this rule: 'border-top', 'border-right', 'border-bottom', 'border-left', 'border', 'background', 'font', 'list-style', 'cue', and 'outline'. 

regards, Gérard
Comment 8 Gérard Talbot (no longer involved) 2009-11-16 23:55:47 UTC
I submitted a precise test regarding this issue to be included in the upcoming CSS 2.1 test suite and it was reviewed and approved by Microsoft (Arron Eicholz):


also at


regards, Gérard
Comment 9 Gérard Talbot (no longer involved) 2010-01-04 22:04:03 UTC
Due to filename numbering conflicts, the URL for the test cases had to be changed. So now, correct URLs:



regards, Gérard
Comment 10 Gérard Talbot (no longer involved) 2010-02-19 20:53:05 UTC
Correct URLs for the testcases:



Testcase in current CSS 2.1 test suite snapshot:

For each and all of those testcases, the tester needs to install the Ahem font, downloadable here:


regards, Gérard
Comment 11 Gérard Talbot (no longer involved) 2010-04-05 04:24:21 UTC
Correct URLs (served as text/html only):


Current snapshot of CSS 2.1 test suite:

regards, Gérard
Comment 12 Andrea Iacovitti 2012-01-05 07:55:29 UTC
Confirmed on linux systems too.
Comment 13 Gérard Talbot (no longer involved) 2012-01-20 04:56:19 UTC
Latest snapshot (served as text/html):
Comment 14 Andrea Iacovitti 2014-05-10 23:57:59 UTC
Git commit f563cf1608ab820d7357fbdbae7ea4886352bf70 by Andrea Iacovitti.
Committed on 10/05/2014 at 23:56.
Pushed by aiacovitti into branch 'KDE/4.13'.

Reject font shorthand property when inherit value is present in font-family subproperty.
FIXED-IN: 4.13.2

M  +16   -8    khtml/css/cssparser.cpp

Comment 15 Gérard Talbot (no longer involved) 2014-05-11 00:59:55 UTC

You may want to check your patch with/against this meta-test:


because it involves 9 sub-tests on inherit (as identifier or not).

You need to have installed the fonts "CSSTest Fallback", "CSSTest FamilyName" and "CSSTest Verify" available at/downloadable from

Comment 16 Gérard Talbot (no longer involved) 2014-05-11 01:02:11 UTC
Comment 17 Gérard Talbot (no longer involved) 2014-06-13 17:29:12 UTC
now pass in Konqueror 4.13.2 

I may create another bug report for sub-test cases in
that Konqueror currently fails.

Status -> VERIFIED

Thank you Andrea !! :)