Why does font-style not work when used in the <BODY> tag?

J

Joshua Beall

I am trying to make all the text on some of my pages smaller using CSS.
What I did was put an inline style setting in the <BODY> tag, as follows:

<body STYLE="font-family: Arial, Helvetica, Sans Serif; font-size:
smaller">

Now, the "font-family" portion works just fine; all my text is Arial,
instead of my system default (Times New Roman). However, no matter what I
set "font-size" to, the font size is unaffected. I have tried smaller,
small, x-small, and xx-smaller. Nothing works.

Obviously I am not doing something right. Can someone enlighten me?

-Josh
 
R

rf

Joshua Beall said:
I am trying to make all the text on some of my pages smaller using CSS.

Why? Why not just use the user settings in your browser to make the text
smaller. That way the text will be "normal" size for everybody else.
What I did was put an inline style setting in the <BODY> tag, as follows:

<body STYLE="font-family: Arial, Helvetica, Sans Serif; font-size:
smaller">

Now, the "font-family" portion works just fine; all my text is Arial,
instead of my system default (Times New Roman). However, no matter what I
set "font-size" to, the font size is unaffected. I have tried smaller,
small, x-small, and xx-smaller. Nothing works.

A wild guess: You have also used tables to layout your page. Some browsers
do not inherit font size into table cells correctly. Use:

body, td {...}

and don't use those things, use percentages and nothing below 100 of them
except perhaps for a copyright notice which you want to make unreadable.

Cheers
Richard.
 
P

Paul Aitch

Joshua Beall said:
I am trying to make all the text on some of my pages smaller using CSS.
What I did was put an inline style setting in the <BODY> tag, as follows:

<body STYLE="font-family: Arial, Helvetica, Sans Serif; font-size:
smaller">

Now, the "font-family" portion works just fine; all my text is Arial,
instead of my system default (Times New Roman). However, no matter what I
set "font-size" to, the font size is unaffected. I have tried smaller,
small, x-small, and xx-smaller. Nothing works.

Obviously I am not doing something right. Can someone enlighten me?

-Josh
Have you tried specifying an actual size in pixcels? e.g.:
.......font-size:20px;

Paul
 
D

David Dorward

Paul said:
Have you tried specifying an actual size in pixcels? e.g.:
......font-size:20px;

Argh. Dear. Me. Please. No.

I'm yet to see a browser which actually gets pixels right (in CSS terms),
and preventing a user from resizing their text (OK OK, its their own fault
for using Microsoft's excuse for a browser, but lots of people make that
mistake) isn't a good idea.
 
S

Sid Ismail

: <body STYLE="font-family: Arial, Helvetica, Sans Serif; font-size:
: smaller">
:
: Now, the "font-family" portion works just fine; all my text is Arial,
: instead of my system default (Times New Roman). However, no matter what I
: set "font-size" to, the font size is unaffected. I have tried smaller,
: small, x-small, and xx-smaller. Nothing works.
:
: Obviously I am not doing something right. Can someone enlighten me?


Have you got tables? then you need to specify
body, td {... }

Problem with inheritance.

URL?

Sid
 
D

David Graham

Joshua Beall said:
I am trying to make all the text on some of my pages smaller using CSS.
What I did was put an inline style setting in the <BODY> tag, as follows:

<body STYLE="font-family: Arial, Helvetica, Sans Serif; font-size:
smaller">

Now, the "font-family" portion works just fine; all my text is Arial,
instead of my system default (Times New Roman). However, no matter what I
set "font-size" to, the font size is unaffected. I have tried smaller,
small, x-small, and xx-smaller. Nothing works.

Obviously I am not doing something right. Can someone enlighten me?

-Josh
Hi
Is that a comma after Sans Serif?
It should be a semi-colon
HTH
David
 
J

Joshua Beall

rf said:
Some browsers do not inherit font size into table cells correctly.

Is this a bug, or does the W3C spec make this an acceptable behaviour?

-jb
 
T

Toby A Inkster

Joshua said:
<body STYLE="font-family: Arial, Helvetica, Sans Serif; font-size:
smaller">

Note: Sans Serif should be "Sans Serif". You're not allowed to use font
names with spaces in them, unless you put quote marks around them.

Or perhaps you meant sans-serif (lower case, with a hyphen) which requests
that the browser uses its default sans serif font.
 
J

Jukka K. Korpela

Joshua Beall said:
Is this a bug, or does the W3C spec make this an acceptable behaviour?

Good question. In principle, there's nothing in the specs that prevents a
browser from having a browser style sheet like
table { font-size: 10.5pt; }
and then there will be no font size inheritance into tables, since
inheritance is _only_ applied when _no_ style sheet specifies the value of a
property of an element.

In practical terms though, it's a bug, albeit maybe intentional.
 
J

Jukka K. Korpela

Toby A Inkster said:
Note: Sans Serif should be "Sans Serif". You're not allowed to use font
names with spaces in them, unless you put quote marks around them.

It's time for my weekly nitpicking:

"Font family names containing whitespace should be quoted. If quoting is
omitted, any whitespace characters before and after the font name are
ignored and any sequence of whitespace characters inside the font name is
converted to a single space."
http://www.w3.org/TR/REC-CSS2/fonts.html#propdef-font-family

So it's indeed "should", not "shall", and we _are_ allowed to use font names
with spaces in them without putting quotation marks around them - though
this is not good practice. It's easier to see the structure of a declaration
when such names are quoted.

And there is currently no such font as "Sans Serif". Anyone and his brother
is allowed to create one, of course. That name wouldn't be a good choice,
though, due to confusion. And you probably couldn't use it as a trademark,
since it resembles a generic expression too much.
Or perhaps you meant sans-serif (lower case, with a hyphen) which requests
that the browser uses its default sans serif font.

The generic font family name sans-serif (which _must not_ be put into
quotation marks) is a CSS keyword, and CSS keywords are case insensitive:

"All CSS style sheets are case-insensitive, except for parts that are not
under the control of CSS."
http://www.w3.org/TR/REC-CSS2/syndata.html#q4

Specific font names, such as "Times New Roman", are considered as not being
under the control of CSS, since they are defined by font designers and by
implementations (and implementations _may_ treat "times new roman" as
another name for "Times New Roman"). Thus they are in principle case
sensitive, though I wonder whether this matters in practice. Anyway, font
manufacturers' common practice is to name the fonts so that all words begin
with a capital letter and other letters are lowercase, so it's usually easy
to use the right case.
 
J

Jukka K. Korpela

Really? They call themselves "the global standard-setting body for the
Web"

They use the word "standard" in a non-standard way, calling themselves even
a "standards body" (though not absolutely directly) at
http://www.w3.org/Consortium/

Recognized international standardization bodies are listed at
http://www.wssn.net/WSSN/listings/links_international.html
Of course standards are rarely legally binding, so I suppose all
standards are recommendations in reality..

Yes, but not all recommendations are standards.

And W3C recommendations would not actually qualify as standards - standards
are far more definite and fixed, not moving targets like W3C
recommendations, which may change at any moment (without prior or posterior
notice) simply by a change to an "Errata" document.

ObHTML: There is an ISO standard for HTML. Virtually nobody uses it, partly
because it was produced in a rather unconstructive way: they took HTML 4.0
Strict and made it stricter, without actually resolving any of the
ambiguities and obscurities in the W3C recommendation that would have needed
some attention.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top