Scripsit Johannes Koch:
Quote:
A browser may treat browser settings as user agent CSS which may be
overridden by author CSS.
Yes, but that's not a sufficient explanation or excuse for the Firefox
behavior.
Suppose that I have
p tt { font-size: 100%; }
in a page ("author") style sheet. How could a browser style sheet "win" it?
First, a browser style sheet could "win" it using !important. That's not the
case here, though, since then it would "win" a page style sheet in all
circumstances, but in fact if you add e.g.
tt { font-family: Courier New, monospace; }
into the page style sheet, the font-size: 100% setting "wins". (This happens
even if Courier New is in use anyway for monospace text!)
Second, a browser style sheet could "win" by using a more specific selector.
That's not the case either. Even though a browser style sheet _could_
contain arbitrarily specific selectors, it does not, in practice. And if it
"won" by doing so, the added rule above would not affect the situation, but
it does.
The conclusion is that Firefox simply misbehaves, as far as CSS compliance
is considered. It has its own weird idea of setting default fonts, making
them depend on "character set" (an undocumented and widely confusing
concept) _and_ making the settings override CSS in a trickish, undocumented,
surprising, Microsoft-like (add derogatory attributes as desired) way.
Basically, Firefox seems to treat its own defaulf font settings as
aggregates that set _both_ font face _and_ font size in a coupled way. If I
set the default monospace font to Courier New 20 (something - I guess it's
pixels, but Firefox doesn't tell me in the interface!), then Firefox will
use this font face and this size for elements like <ttunless a page sets
the font face for such an element, using an explicit font name (monospace
won't do). Setting the font size alone does not seem to take effect.
If I were paid (a lot) for defending Firefox against all unjustified and
justified criticism, I might try the explanation that in Firefox, the
default monospace font, and the specific value corresponding to the generic
font name monospace in CSS, is a virtual font that has the following
characteristics. It physically looks like the font specified in the user
interface for selecting the default monospace (or by factory settings), but
it only exists in the size specified in the same interface (or factory
settings). Thus, no matter what font size you set, the actual value is the
same.
I'm afraid the God's (or Devil's?) advocate would attack my argument using
<div>Hello <tt>Hello <span>Hello</spanHello</tt></div>
and
tt { font-size: 100%; }
span { font-family: Times New Roman }
which should, according to my argument, result in the <spanelement
displayed in normal font size, since its font size would be 100% of the
_computed_ font size of its parent. But as you may guess, it's in reduced
font size.
Thus, the verdict is that Firefox is simply wrong.
As a workaround, use something like
pre, code, samp, kbd, tt
{ font-family : "Courier New", monospace;
font-size: 100%;
font-style : normal; }
(I'm assuming that you really want 100% font size for monospace text. I
think it's generally not a good idea, since typical monospace fonts, and
especially Courier New, look bigger than normal text in the same font size.
For isolated code fragments, 100% might be OK, but inline fragments become
too big with respect to surrounding text.)
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/