473,545 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2808
Roedy Green <se*********@mi ndprod.com.inva lidwrites:
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*********@mi ndprod.com.inva lidwrites:
>Is there a shortcut way to define the default font family (and
characteristic s) 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.tu t.fiwrites:
Scripsit Sherman Pendley:
>Roedy Green <se*********@mi ndprod.com.inva lidwrites:
>>Is there a shortcut way to define the default font family (and
characteristi cs) 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",Tiresia sScreenfont,"Pa latino Linotype","Book man Old
Style","Book Antiqua","Trebu chet MS","Lucida Sans","Lucida Sans
Unicode",Verdan a,serif;

for title-like elements:
font-family: Calibri,"Bitstr eam Vera Sans","Segoe
UI",Arial,Helve tica,sans-serif;

for monospaced elements:
font-family: "Bitstream Vera Sans Mono","Lucida
Console","Lucid a Sans","Lucida Sans Unicode","Couri er","Courier
New","Bitstrea m Vera Sans","Segoe UI",Arial,monos pace;

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*********@mi ndprod.com.inva lidwrites:
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",Tiresia sScreenfont,"Pa latino Linotype","Book man Old
Style","Book Antiqua","Trebu chet MS","Lucida Sans","Lucida Sans
Unicode",Verdan a,serif;

for title-like elements:
font-family: Calibri,"Bitstr eam Vera Sans","Segoe
UI",Arial,Helve tica,sans-serif;

for monospaced elements:
font-family: "Bitstream Vera Sans Mono","Lucida
Console","Lucid a Sans","Lucida Sans Unicode","Couri er","Courier
New","Bitstrea m Vera Sans","Segoe UI",Arial,monos pace;

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">Fe e 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#sp ecificity>

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="monospac e 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.tu t.fiwrote:
Scripsit Sherman Pendley:
Roedy Green <se*********@mi ndprod.com.inva lidwrites:
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.tu t.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*********@mi ndprod.com.inva lidwrites:
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

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

Similar topics

131
21536
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 get some good real world examples. Fire away! :) Regards, Peter Foti
55
4937
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 text when the user uses the default font size in his browser and uses the typical display resolution. I did a reinstall of my friendly browser in...
115
7110
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 ..." Yet if I use 'x-small' instead of 9pt, I get bigger type on IE6 and smaller type on Mozilla. My choices seem to be:
21
2844
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 that someone actually suggested ems as a reference. Ems are relative to a selected point size, the width in points of a capital M. If no point size...
0
3035
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 (through a dialog). It works fine fo W98, 2000, NT, and XP is the theme is Classic. But on XP if the theme is "Windows XP", the we have a problem: if...
60
4712
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 = 81.25
2
2534
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: MessageBox.Show("250\u2009000 points");
30
4498
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 work: ;;; p {
71
5738
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 points the same way, at least within the browser window). It has been suggested that one should use ems to allow browsers to increase or decrease the...
58
5709
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 style="font-family:Verdana,Arial,Helvetica;font-size:80%;"> to no avail. In IE7 it shows up as Medium. What did I do wrong? Thanks.
0
7457
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7651
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7802
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7410
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7746
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5320
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3438
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1869
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1010
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.