Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting default font size 1

Status
Not open for further replies.

OsakaWebbie

Programmer
Feb 11, 2003
628
JP
Because I have forms laid out in tables and stuff, I want to somewhat control the fonts that are displayed (rather than just letting the browser's defaults prevail - some things wrap in unpleasant ways). Before you say anything, yes, I am aware that I won't get exactly the same thing on all OSs and browsers, but I want a decent starting point (and due to other browser-specific stuff in my code, most or all my users will be on Windows/IE anyway, most of them in the Japanese version).

Because I use PHP to define the header stuff in a common routine, I didn't bother with a separate CSS file, but was doing the following in the head of my document:

Code:
<STYLE TYPE=&quot;TEXT/CSS&quot;>
<!--
BODY {font-family: arial, helvetica, sans-serif; font-size: 10pt;}
-->
</STYLE>

In case it matters, my pages are specifying character set UTF-8, which seems (at least on my machine) to default to a serif font (when I was previously using Shift-JIS instead, the default was a pleasantly sized sans-serif font, but I don't know how to find out what font face and size it was). The font-family setting in the above code works, but the font-size doesn't (the default at the middle size setting on my browser is a little too big - I don't know yet if 10pt is what I want, but once I get the code to work, I can experiment). If I define the font-size in a P element rather than BODY, it works for things that are P, but most of my text is just in table cells and doesn't use the P tag. Does BODY only support a subset of the things that you can define for other tags? Does anyone know if I can do what I want? (I definitely don't want to add <font> tags to all my code - we're talking about a lot of code!) Thanks!
 
Different browsers will inherit the styles differently, so to be on the safe side, just force the font to every element that uses fonts, like this:
Code:
<STYLE TYPE=&quot;TEXT/CSS&quot;>
<!--
body,p,div,span,td,input,textarea {font-family: arial, helvetica, sans-serif; font-size: 10pt;}
-->
</STYLE>
Voila, everyone of these elements (unless specified differently) will carry this font. Hope it helps.
 
Thanks - that did work. Looking at the list of elements, I guess TD was the one that must have been cancelling out what I was trying to do by using BODY - just about everything in this site is in a table (sometimes a table inside a table inside a table). I assume that if at some point I want to override this setting with a DIV or SPAN I can do it inside a specific tag, right?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top