Re: Question on parsing of "font" property

Boris Zbarsky wrote:

>
> I was asked what the right parsing of the following CSS is:
>
>   font: 10px /2 Times;
>
> (note the space before the '/'), and it seems to me that this could be 
> parsed as either:
>
>   font-size: 10px;
>   font-family: /2 Times;
>
> or
>
>   font-size: 10px;
>   line-height: 2;
>   font-family: Times;
>
> Both look to be valid, no?
>
> -Boris
>
>
well neither are valid, if I recall correctly, since line-height needs a 
qualifying <length> value which the literal 2 is not, and if I also 
recall correctly any non-alpha-numeric value in font-family would make 
the whole family be quoted.

::goes to double check CSS 2.1 to make sure he is not spouting incorrect 
material::

ick, I was incorrect...

Well taking into account the exact syntax in the spec:

/Value:/  [ [ <'font-style'> 
<http://www.w3.org/TR/CSS21/fonts.html#propdef-font-style> || 
<'font-variant'> 
<http://www.w3.org/TR/CSS21/fonts.html#propdef-font-variant> || 
<'font-weight'> 
<http://www.w3.org/TR/CSS21/fonts.html#propdef-font-weight> ]? 
<'font-size'> <http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size> 
[ / <'line-height'> 
<http://www.w3.org/TR/CSS21/visudet.html#propdef-line-height> ]? 
<'font-family'> 
<http://www.w3.org/TR/CSS21/fonts.html#propdef-font-family> ] | caption 
| icon | menu | message-box | small-caption | status-bar | inherit 
<http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit>

BZ's comments should be addressed in both the spec and here

Received on Tuesday, 18 May 2004 21:46:08 UTC