Scripsit Takehiko Abe:
I have a <pelement with <ttinside:
- -
I would like to set the font-size of the TT to the same
as the containing <p>.
That would be
p tt { font-size: 100%; }
or, equivalently by the specifications,
p tt { font-size: 1em; }
This does not seem to work:
;;; p {
;;; font-size: medium;
;;; }
The font size of the p element is irrelevant for the purposes of the stated
problem, except if you used physical units like px or mm, and you shouldn't
use them.
Besides, this particular setting, which uses medium as font-size value, is
not recommendable, since its effect depends on the browser. Even on IE 7,
you get different results depending on "standards mode" vs. "quirks mode".
;;; p tt {
;;; font-size: 100%;
;;; }
What do you mean by saying that it does not work? Note that the visual
appearance of a monospace font may give the impression of increased font
size. This may sound self-contradictory to most people, since most people do
not know what "font size" really means.
Letters are generally larger (taller) in a monospace font than in a
proportional font of the same size. This is probably the main reason why
many browsers use reduced font size for elements that are usually rendered
in a monospace font, so that the effect might correspond to something like
tt, code, samp, pre, textarea { font-size: 90% }. You can see whether this
is the case in your browser by using
tt, code, samp, pre, textarea { font-family: Times New Roman; }
Similarly, you can test test whether
p tt { font-size: 100%; }
takes effect, if you add the rule
p, p tt { font-family: Times New Roman; }
(You could use just p tt { font-family: inherit; }, but IE doesn't support
it.)
when default sizes for propertional and monospace fonts
are set to different values in a browser.
Unless there's some bad browser bug involved, those default sizes should
have no effect when font-size is set. In theory, browser settings _might_
conceptually map to CSS rules with !important specifier, but I don't think
things are that way, and if they are, there's nothing you can do about it as
an author - !important is _meant_ to be the user's last resort and give him
the final word.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/