473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

font default

Is there a shortcut way to define the default font family (and
characteristics) to be applied to all styles?
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Aug 2 '08 #1
14 2794
Roedy Green <se*********@mindprod.com.invalidwrites:
Is there a shortcut way to define the default font family (and
characteristics) to be applied to all styles?
Just apply it to the top-level body rule:

body { font: 1em serif }

Elements nested in the body element will inherit its styles - that's
the C (for Cascade) in CSS.

sherm--

--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
Aug 2 '08 #2
Scripsit Sherman Pendley:
Roedy Green <se*********@mindprod.com.invalidwrites:
>Is there a shortcut way to define the default font family (and
characteristics) to be applied to all styles?

Just apply it to the top-level body rule:

body { font: 1em serif }
The question presumably refers to browser default font family. What
makes you think it is a serif font and that it is the font corresponding
to the keyword serif? Hint: You have no grounds for that,
Elements nested in the body element will inherit its styles - that's
the C (for Cascade) in CSS.
You don't understand the "C" in "CSS". Neither do most other authors,
but this is a good reason to refrain from giving advice on CSS in public
before you have a clue.

Look at the rendering of an <inputelement for example.

The correct answer is that the "best" one can do is
* { font-family: inherit !important; }
but this
a) isn't supported by IE
b) is ineffective against style sheets that use the !important weapon
too.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Aug 2 '08 #3
"Jukka K. Korpela" <jk******@cs.tut.fiwrites:
Scripsit Sherman Pendley:
>Roedy Green <se*********@mindprod.com.invalidwrites:
>>Is there a shortcut way to define the default font family (and
characteristics) to be applied to all styles?

Just apply it to the top-level body rule:

body { font: 1em serif }

The question presumably refers to browser default font family. What
makes you think it is a serif font and that it is the font
corresponding to the keyword serif? Hint: You have no grounds for
that,
I think no such thing. Hint: You have no grounds for believing
yourself to be psychic.
>Elements nested in the body element will inherit its styles - that's
the C (for Cascade) in CSS.

You don't understand the "C" in "CSS". Neither do most other authors,
but this is a good reason to refrain from giving advice on CSS in
public before you have a clue.
You don't understand basic manners. This is a good reason to refrain
from speaking to others before you have a clue.
The correct answer is that the "best" one can do is
* { font-family: inherit !important; }
but this
a) isn't supported by IE
b) is ineffective against style sheets that use the !important weapon
too.
So, your "correct answer" is one that doesn't work for 70-80% of the
real users who will visit a site? Typical ivory-tower bullshit - and
precisely what I've come to expect from you.

*plonk*

sherm--

--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
Aug 2 '08 #4
On Sat, 02 Aug 2008 13:40:16 -0400, Sherman Pendley
<sp******@dot-app.orgwrote, quoted or indirectly quoted someone who
said :
>body { font: 1em serif }
Thanks for your speedy response. I realise now that I do that
already. Here is a related question, which is the one I should have
asked in the first place.

What if you have 3 basic font-family patterns on your website? e.g.

for body text
font-family: "Tiresias PCfont Z","Tiresias
PCfont",TiresiasScreenfont,"Palatino Linotype","Bookman Old
Style","Book Antiqua","Trebuchet MS","Lucida Sans","Lucida Sans
Unicode",Verdana,serif;

for title-like elements:
font-family: Calibri,"Bitstream Vera Sans","Segoe
UI",Arial,Helvetica,sans-serif;

for monospaced elements:
font-family: "Bitstream Vera Sans Mono","Lucida
Console","Lucida Sans","Lucida Sans Unicode","Courier","Courier
New","Bitstream Vera Sans","Segoe UI",Arial,monospace;

Is there a way to specfy each pattern only once, then just indicate
which pattern applies to any given style?

If not, is there a way to specify the preferred font-family set you
would like to use for logical fonts monospace , sans-serif and serif?

If not, is there any way to create user-defined inheritance hierarchy
using category names rather than repeating use of tag names on
multiple style definitions or are you stuck with mirroring the HTML
tag structure?

I heard CSS was developing constants/variables, that might be useful
to solve such a problem. How is that coming along?
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Aug 2 '08 #5
Roedy Green <se*********@mindprod.com.invalidwrites:
On Sat, 02 Aug 2008 13:40:16 -0400, Sherman Pendley
<sp******@dot-app.orgwrote, quoted or indirectly quoted someone who
said :
>>body { font: 1em serif }

Thanks for your speedy response. I realise now that I do that
already. Here is a related question, which is the one I should have
asked in the first place.

What if you have 3 basic font-family patterns on your website? e.g.

for body text
font-family: "Tiresias PCfont Z","Tiresias
PCfont",TiresiasScreenfont,"Palatino Linotype","Bookman Old
Style","Book Antiqua","Trebuchet MS","Lucida Sans","Lucida Sans
Unicode",Verdana,serif;

for title-like elements:
font-family: Calibri,"Bitstream Vera Sans","Segoe
UI",Arial,Helvetica,sans-serif;

for monospaced elements:
font-family: "Bitstream Vera Sans Mono","Lucida
Console","Lucida Sans","Lucida Sans Unicode","Courier","Courier
New","Bitstream Vera Sans","Segoe UI",Arial,monospace;

Is there a way to specfy each pattern only once, then just indicate
which pattern applies to any given style?
No, unfortunately CSS has no means of defining macros, constants, or
other such things. :-(

What I would do is define a selector that lists a number of element
names, as well as a class, for each of the above patterns:

P,DIV,.body { font-family: ... }
H1,H2,H3,H4,H5,H6,.title { font-family: ... }
PRE,.monospace { font-family: ... }

Then, if you needed a H5 to look like body text, you could mark it up
with a class attribute:

<h5 class="body">Fee fie fo fum.</h5>

This works because a class selector has a higher specificity than an
element name. For the above element, the first rule matches the class,
so it has a specificity value of 10, where the second only matches the
element name, so it has a value of 1. So, the first rule "wins".

<http://www.w3.org/TR/REC-CSS2/cascade.html#specificity>

You can supply more than one class for a given element. So, let's
define a class "callout" that floats a DIV to the right:

DIV.callout { float:right }

If you want a particular callout div to use monospaced text, you could
give it both class names, separated by spaces:

<div class="monospace callout">...</div>

The "multiple classes" is what allows you to do what I think you want
to do, to define rules that define a font-family, and apply those
rules in addition to rules that define other style properties.

Note also that, because the rules that define your font-families
include selectors based on element names, you'd only need to add a
class attribute to elements for which you wanted to override the
"default" font-family for their type.
I heard CSS was developing constants/variables, that might be useful
to solve such a problem. How is that coming along?
Dave Hyatt has written a proposal, and given his position on the
Safari dev team, I'd expect it to be implemented in KHTML/Safari soon,
if it hasn't been already:

<http://disruptive-innovations.com/zoo/cssvariables/>

I've no idea when (or if) other browsers will implement his proposal.

sherm--

--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
Aug 2 '08 #6
On Sat, 02 Aug 2008 17:01:04 -0400, Sherman Pendley
<sp******@dot-app.orgwrote, quoted or indirectly quoted someone who
said :
>No, unfortunately CSS has no means of defining macros, constants, or
other such things. :-(
hmm. If I used three different style sheets could I set up different
body defaults for the three sheets in some way what would then provide
the base for inheritance of the styles defined in that sheet?

Or all the three sheets logically one big one?
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Aug 2 '08 #7
In article <6J******************@reader1.news.saunalahti.fi >,
"Jukka K. Korpela" <jk******@cs.tut.fiwrote:
Scripsit Sherman Pendley:
Roedy Green <se*********@mindprod.com.invalidwrites:
Is there a shortcut way to define the default font family (and
characteristics) to be applied to all styles?
Just apply it to the top-level body rule:

body { font: 1em serif }

The question presumably refers to browser default font family. What
makes you think it is a serif font and that it is the font corresponding
to the keyword serif? Hint: You have no grounds for that,
It would be a funny question if it did refer to browser default font
family considering one does not need to specify anything to let the
default call the tune. Hint: that's what default means.

Korpela misses that Sherm's is merely an example and might be changed to
suit real circumstances.

--
dorayme
Aug 2 '08 #8
In article <m1************@dot-app.org>,
Sherman Pendley <sp******@dot-app.orgwrote:
"Jukka K. Korpela" <jk******@cs.tut.fiwrites:
Scripsit Sherman Pendley:
precisely what I've come to expect from you.

*plonk*

sherm--
I am sure you plonked him a while back. Are you a bit of a softie Sherm
with a time lock on your killfile?

--
dorayme
Aug 2 '08 #9
Roedy Green <se*********@mindprod.com.invalidwrites:
On Sat, 02 Aug 2008 17:01:04 -0400, Sherman Pendley
<sp******@dot-app.orgwrote, quoted or indirectly quoted someone who
said :
>>No, unfortunately CSS has no means of defining macros, constants, or
other such things. :-(

hmm. If I used three different style sheets could I set up different
body defaults for the three sheets in some way what would then provide
the base for inheritance of the styles defined in that sheet?
I'm not sure just what you're asking. Stylesheets don't inherit, all
they do is define which elements a set of style properties are applied
to. The effect of those properties is subject to inheritance, but the
selection of what elements the properties will be applied to is not.

Inheritance comes into play when a browser needs to decide how to
render an element to which no explicit style has been applied; in that
case, the browser looks to the element's parent, grandparent, etc. to
find the value the child should inherit for that property. At that
point, it's irrelevant which (if any) stylesheet was used to apply
the property to the ancestor element; it's the property value that's
inherited, not the rule that was used to apply it.

sherm--

--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
Aug 2 '08 #10
dorayme <do************@optusnet.com.auwrites:
I am sure you plonked him a while back.
Different group. :-)

sherm--

--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
Aug 2 '08 #11
On Aug 2, 1:40*pm, Sherman Pendley <spamt...@dot-app.orgwrote:
Roedy Green <see_webs...@mindprod.com.invalidwrites:
Is there a shortcut way to define the default font family (and
characteristics) to be applied to all styles?

Just apply it to the top-level body rule:

body { font: 1em serif }

Hello Sherman,

I definitely recommend to *_not_* use 1em and instead use 100% because
there is an important bug in IE 5, IE 6 and IE 7 which will be
triggered with font: 1em serif.

http://www.gtalbot.org/BrowserBugsSe...IE7Bugs/#bug79

Regards, Gérard
--
Internet Explorer 7 bugs: 159 bugs so far
http://www.gtalbot.org/BrowserBugsSection/MSIE7Bugs/
Aug 3 '08 #12
Scripsit Sherman Pendley:

[...]
>>>Is there a shortcut way to define the default font family (and
characteristics) to be applied to all styles?

Just apply it to the top-level body rule:

body { font: 1em serif }

The question presumably refers to browser default font family. What
makes you think it is a serif font and that it is the font
corresponding to the keyword serif? Hint: You have no grounds for
that,

I think no such thing.
So you apparently weren't asking the question in its obvious meaning,
and you didn't specify which question you answered. It doesn't really
matter, since whatever the question was, within reasonable limits, your
answer was wrong.
>>Elements nested in the body element will inherit its styles - that's
the C (for Cascade) in CSS.

You don't understand the "C" in "CSS". Neither do most other authors,
but this is a good reason to refrain from giving advice on CSS in
public before you have a clue.

You don't understand basic manners.
If "basic manners" includes the principle of not revealing bogus answers
in public as bogosity, I'm very happy to fail to meet your definition of
"basic manners".

Thank you for confirming your ignorance of the basics of CSS by making a
personal attack instead of even trying to defend the statements you
wrote.
>The correct answer is that the "best" one can do is
* { font-family: inherit !important; }
but this
a) isn't supported by IE
b) is ineffective against style sheets that use the !important weapon
too.

So, your "correct answer" is one that doesn't work for 70-80% of the
real users who will visit a site?
Quite correct: my answer describes the "best", i.e. the maximum of what
you can achieve in CSS, in the direction of the goal described in the
question. It seems that you have already forgotten the question, or
never understood it.

Of course, if we modify the question, we get more useful questions with
more useful answers (which don't include yours), but I will leave it to
the OP to explain what he really wants, if it still matters.

For example, if you really wanted to use the same specific font, say
Arial, with each browser's meaning for sans-serif as the fallback
option, for _all_ elements, _then_ the following is fairly effective:
* { font-family: Arial, sans-serif !important; }
Beware that this would affect elements for which such rendering would be
unnatural or risky (e.g. <codeand <pre>) and that it would not affect
the rendering of some form fields in some browsers (which present such
fields using built-in routines that are immune to CSS rules).

(It would be slightly more effective, but boring, to write a long list
of elements - all HTML elements you know of - before "*":
a, abbr, acronym, ..., xmp, * { ... } )

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Aug 3 '08 #13
Scripsit Roedy Green:
>body { font: 1em serif }

Thanks for your speedy response. I realise now that I do that
already.
Then you should do something about that problem.
Here is a related question, which is the one I should have
asked in the first place.
We might be getting closer to your real question, and it isn't related
to the question you originally asked.
What if you have 3 basic font-family patterns on your website?
You just decide which elements you wish them to apply to, then write
appropriate selector lists.
e.g.

for body text
font-family: "Tiresias PCfont Z","Tiresias
PCfont",TiresiasScreenfont,"Palatino Linotype","Bookman Old
Style","Book Antiqua","Trebuchet MS","Lucida Sans","Lucida Sans
Unicode",Verdana,serif;

for title-like elements:
font-family: Calibri,"Bitstream Vera Sans","Segoe
UI",Arial,Helvetica,sans-serif;

for monospaced elements:
font-family: "Bitstream Vera Sans Mono","Lucida
Console","Lucida Sans","Lucida Sans Unicode","Courier","Courier
New","Bitstream Vera Sans","Segoe UI",Arial,monospace;
How many of the possible combinations did you actually test visually? It
seems that you have written the lists almost at random. For example,
what will happen when Verdana is used for copy text, Calibri for
headings, and Arial for "monospaced" elements? Quite a mess, I would
say.

For example, what does Verdana do in the list for body text
alternatives? It would seldom be used, since e.g. Palatino Linotype has
probably well over 90% coverage in computers, but if it were used for
some odd reason, the page appearance would be _very_ different from the
effects of most of the other fonts you're suggesting.

The Tiresias fonts are rather rarely installed, but if you have verified
that their overall appearance is similar to Palatino Linotype but even
better for your purposes, then the following would be a reasonable
starting point:

* { font-family: "Tiresias PCfont Z","Tiresias
PCfont",TiresiasScreenfont,"Palatino Linotype", serif; }

Then you just add rules for elements for which some other font is
preferred.

For title-like elements, you have too many alternatives, too. For
example, what are the odds of having Segoe UI in a system that lacks
Calibri? And what is your general strategy? If you prefer Calibri for
title-like elements, it would be natural to use Cambria or Constantia
for copy text, Consolas for monospace text, since the "C fonts" have
been designed to be used together. They are generally smaller than most
other fonts, for a given font size (!), but they match each other's
dimensions, so that e.g. Consolas text inside Cambria text looks
reasonable (whereas, in general, monospace text inside normal text too
often looks disproportional).

For example, assuming that Palatino Linotype is really your basic
preference for copy text, you should probably have something simple for
title-like elements, e.g.
h1, h2, h3, h4, h5, h6, caption, th, .caption {
font-family: Helvetica, Arial, sans-serif; }
(and you would use class="caption" for any element that you want to
appear in your "title style" but lacks natural markup, e.g. image
caption).
Is there a way to specfy each pattern only once, then just indicate
which pattern applies to any given style?
No.
If not, is there a way to specify the preferred font-family set you
would like to use for logical fonts monospace , sans-serif and serif?
By using a list of selectors that contains the elements you want the
font-family to be used for.
If not, is there any way to create user-defined inheritance hierarchy
No. Inheritance works as defined in CSS specifications, and in a manner
that most people don't understand. Forget inheritance for the time
being. If you specify font-family for every element (as you would e.g.
by writing * { font-family: ... }), then no inheritance will take place
for that property.
I heard CSS was developing constants/variables, that might be useful
to solve such a problem.
The Internet is full of rumors. This one is particularly wrong, since
the W3C has made a policy decision not to develop CSS in the direction
of a programming language. Of course, they might be somewhat
inconsistent in this matter, as others, but it would be very unrealistic
to expect CSS to develop (named) constants or variables.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Aug 3 '08 #14
GTalbot <ne*******@gtalbot.orgwrites:
On Aug 2, 1:40*pm, Sherman Pendley <spamt...@dot-app.orgwrote:
>Roedy Green <see_webs...@mindprod.com.invalidwrites:
Is there a shortcut way to define the default font family (and
characteristics) to be applied to all styles?

Just apply it to the top-level body rule:

body { font: 1em serif }


I definitely recommend to *_not_* use 1em and instead use 100% because
there is an important bug in IE 5, IE 6 and IE 7 which will be
triggered with font: 1em serif.
It was just a quick example - but still, you're right. I'd forgotten
about that bug. Thanks for the reminder.

sherm--

--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
Aug 3 '08 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

131
by: Peter Foti | last post by:
Simple question... which is better to use for defining font sizes and why? px and em seem to be the leading candidates. I know what the general answer is going to be, but I'm hoping to ultimately...
55
by: Haines Brown | last post by:
I've been setting font-size 1em; as the default in my style sheets. Until now, that seemed to be ok. But now I'm beginning to wonder. My aim is to have an easily readable, but not overly large...
115
by: J | last post by:
I've run CSSCheck on my style sheets and I always get a warning similar to this: "font: bold 9pt/100% sans-serif Warning: Absolute length units should not generally be used on the Web ..." ...
21
by: James Moe | last post by:
Hello, I just joined this group and saw the discussion "What do you think of resizing 1em to 10px?" I am somewhat confused by what y'all think should be used as a reference size. I was surprised...
0
by: Chenghui Li | last post by:
We have a problem with the Windows XP theme: We have a IDE which allows other developers to develop visual programs for their customers. Our IDE allow them to set font for window captions easyly...
60
by: deko | last post by:
As I understand it, most browser manufacturers have agreed on 16px for their default font size. So, this should be an accurate conversion for percentages: px % 16 = 100 14 = 87.5 13 =...
2
by: alberto.ribao | last post by:
Hello, I'm making some proofs of concept about localization with .NET Framework 2.0 My trouble is I'm trying to display the next string with a call to MessageBox.Show method: ...
30
by: Takehiko Abe | last post by:
I have a <pelement with <ttinside: ;;; <p>A paragraph contains <tt>tt element</tt>.</p> I would like to set the font-size of the TT to the same as the containing <p>. This does not seem to...
71
by: Mark | last post by:
Sorry if the question is a bit basic. I generally express my font sizes in pixels, originally to handle the Macintosh/Windows font size differences (though I believe that they both now treat...
58
by: Don Li | last post by:
I've tried <body style="font-family:Verdana,Arial,Helvetica;font-size:0.8em;"> or <body style="font-family:Verdana,Arial,Helvetica;font-size:11pct;"> or <body...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.