Forum Moderators: not2easy

Message Too Old, No Replies

Font sizes in CSS

Overriding them via the browser

         

GuanoLad

4:25 am on Oct 9, 2002 (gmt 0)

10+ Year Member



Some people wish to be able to override the font settings I have put on my website using their browser settings. I thought they could already, but it turns out that my settings truly are fixed at the pixel size I've specified. At least, so it is in IE6.

So if I want to make them adjustable, but have the default settings exactly as I've specified currently - i.e. when visitors arrive, no matter their current settings they'll get what I have set - but after that they can adjust to whatever they want - how do I do that?

I may be asking too much. I currently use the px setting for font sizes. Does the em or pt or whatever setting make a difference in that regard?

I just don't want to change my settings to percentages and end up with chunky text - I really like my carefully selected sizes, it's a shame if I now have to jigger around to get it looking right again only to discover everybody sees everything their own way if I do that.

keyplyr

7:01 am on Oct 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Does the em or pt or whatever setting make a difference in that regard?

Yes. If you change from px to em, the user may then adjust the font size.

tedster

8:04 am on Oct 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



only to discover everybody sees everything their own way if I do that

That's what will happen - 1 em is whatever default font the user has configured in their browser.

when visitors arrive, no matter their current settings they'll get what I have set - but after that they can adjust to whatever they want - how do I do that

A change of units won't accomplish this goal. You'd need to create one or more extra style sheets and then give the user an onscreen option through scripting to select the one they prefer.

GuanoLad

8:26 am on Oct 9, 2002 (gmt 0)

10+ Year Member



Hmm. This is kind of disappointing. I experimented with EM just now and that was a minor disaster. It seemed to take 'relative' a lot more literally and confused me. It looks like I'd have to totally rearrange entire pages (or maybe just my stylesheet order) to make it do what I want logically.

I've seen webpages on HTML and CSS and some say 'relative is best' some say 'absolute is best'. Coupled with frustration at the mixture of what has been adopted in each browser version. It appears to be just use whatever works right for you.

A javascript thingy that will auto detect and set up different stylesheets seems to be a hell of a complicated way to go for something that should be so simple.

I am torn.

Purple Martin

9:24 am on Oct 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I experimented with EM just now and that was a minor disaster. It seemed to take 'relative' a lot more literally and confused me.

Remember that ems inherit. This means that the em value of an element is rendered relative to the em value of it's parent element. So, if you have one element set to 1.2em inside a parent element set to 1.3em, the text size will be 1.56 times bigger than the user's default browser size (because 1.3 of 1.2 = 1.56). I've got a feeling this will explain your unexpected results.

starway

10:01 am on Oct 9, 2002 (gmt 0)

10+ Year Member



Exactly Purple Martin, you're right.
So if you don't want to bother yourself with elements inheritance, use points (pt) for text size: it will be exactly the same as you specified in any page element, and your visitors will be able to change the text size via browser interface.
Just remembr that NN4 shows different size for some values.

GuanoLad

8:05 am on Oct 17, 2002 (gmt 0)

10+ Year Member



pt does the same as px - I still can't change font size after changing it.

starway

8:31 am on Oct 17, 2002 (gmt 0)

10+ Year Member



It's because you test it in IE. Don't know about IE6 (I don't have it), but IE5 doesn't allow to do such a basic thing.
Other browsers do this perfectly.

ALWAYS tell what browser you are testing in.

SmallTime

9:40 am on Oct 17, 2002 (gmt 0)

10+ Year Member



pt size is about the least reliable method for specifying font size, it is different mac/pc, older mac/newer mac, and screen resolution.

all the schemes for relative sizing suffer from cross browser cross OS problems, although using font-size in css hacked to accommodate different default font sizes (ie setting font-size: small, or x-small depending on browser, IE 5 gets x-small, IE5/Mac, Netscape 6, Mozilla, IE6/Win get small) and using a different stylesheet for NN4 with fixed sizes, seems to come closest to working. It doesn't give you much at all to work with in terms of a range of sizes, but at least it isn't tiny or huge without warning.

No good solution is the bottom line. I generally set px sizes, and leave them a little larger than I might otherwise.

Every browser should have Opera's zoom page function.

Trisha

7:45 pm on Oct 17, 2002 (gmt 0)

10+ Year Member



I was never sure of what to do about this either because of the problems/inconsistencies with the way browsers dislay non-pixal relative font sizes. After reading that recent Wired article about how they changed to CSS, I looked at their .css files and saw that they were using %'s. I then tried percents also, and it seems to be working ok in IE 5.5, NN 4.x, 6.2 and Opera 6.?

Does anyone know of any problems associated with percents that I should be aware of?

jamie

11:33 am on Oct 18, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



isn't % similar to use as em?

but it does let itself be overridden much better by the browser (IE 5 and above).

i.e. if you set font size to 1em and then try and manually set Text Size in the browser to 'larger' or 'smaller', it magnifies or minimizes it to the extreme.

whereas if the font size is set using %, then 'larger' just makes it a bit larger, and 'smaller' a bit smaller - much easier to fine tune.

correct if wrong, i am actually in process of learning all this myself ;)

zollerwagner

8:17 pm on Dec 4, 2002 (gmt 0)

10+ Year Member



Hello,

I've found this article on text sizing very helpful:
[alistapart.com...]

I've had trouble with ems and more recently with the relative sizes (small, large, etc.). When the dust settles and browsers finally render text similarly with ems, I'll go back to them.

In fact, I was using javascript sniffer to hand off different style sheets to different browser platform combos. This used to work fairly well, but now that IE6 does font sizes differently, the sniffer and number of style sheets got unwieldy.

Well, maybe they didn't work all that well. As the article points out, you have to guess what settings the user has set for their display--an impossibility.

I'm moving to px for sizing text and I'm trying to do it with just one style sheet.

I'm not worried about accessibility at this point because an "expert" at Human Factors once told me that people who really need huge text have special programs that expand pages for them. So they don't even use the methods the W3C calls for!

Nick_W

8:23 pm on Dec 4, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What about people like me that just have bad eyes?

I'm not saying don't use px but don't be fooled into thinking that hard coding font sizes is okay. It's not. Many people fall into a category between needing special programs and normal vision.... just people with short/long vision and all the many variations of eye problems that are extremely common in ordinary folk.

Just my thoughts, and I don't always follow my own ideals either ;)

Nick

zollerwagner

8:58 pm on Dec 4, 2002 (gmt 0)

10+ Year Member



I hear you. My wife hates to wear her glasses and complains about small text. What she did was to set her 17" monitor's screen resolution to 640 so that everything in the display is super-sized. I hate reading things on her screen, but she's happy.

You'll probably have to scroll to see non-fluid sites that have been designed for 800 or larger, but everything is a compromise, isn't it?

The key here, I think, is that no matter what designers do, you can decide how big you want the text to be.

imaputz

2:27 am on Dec 5, 2002 (gmt 0)

10+ Year Member



I'm not worried about accessibility at this point because an "expert" at Human Factors once told me that people who really need huge text have special programs that expand pages for them. So they don't even use the methods the W3C calls for!

First I've heard of this. Unless it's a standard magnifier application. Any chance you know the names of the programs? I like to try them out.

pageoneresults

2:42 am on Dec 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In IE, if you go to...

Tools > Internet Options > Accessibility

...you'll find where users with visual disabilities can override any style sheets. The biggest problem I see with relative fonts is that most people are not aware they have the ability to add a button to their IE toolbar that will allow them to adjust their font size. Nor are they aware that you can go to...

View > Text Size

...and choose from 5 different font size settings with Medium being the default setting. There are just too many variables involved when it comes to using ems or any relative font size unit. IE I believe is the only browser that lets the designer take control of font sizing away from the average user. All the other browsers do not. But, since IE is the predominant browser, you've got to work around its faults and try to come to a happy medium for all browsers. If that is possible.

zollerwagner

3:48 am on Dec 5, 2002 (gmt 0)

10+ Year Member



PageOneResults is right on.

I'll try to find the names of the programs used to magnify the display. I'm not sure I've got them, but I've talked to a friend who was using them. He said that he never had trouble zooming in on text, to my surprise.

copongcopong

12:44 am on Dec 6, 2002 (gmt 0)

10+ Year Member



Try to create form that would allow user to change the font size in your page, On my site, here is what I did.

The form changes the font size of body and p tag in px.

Then I set the font size of the information (some div's and span's) to em.

Since em inherits the parent size (which is body and p tag), when you change the font size for body and p tag, the whole document would follow .

best of both worlds. Em and Px. :)

zollerwagner

3:31 am on Dec 6, 2002 (gmt 0)

10+ Year Member



That's an interesting idea. Do you have a link we could visit to try it out?

zollerwagner

3:47 am on Dec 6, 2002 (gmt 0)

10+ Year Member


Okay, Here's a lead on software for limited vision folks. There are, as I understand it, two basic technologies. One of them reads (verbally) the page to the user (JAWS, IBM Home Page Reader, outSpoken); the other just magnifies the page visually (Magic, Screen Magnifier, InLarge). Some people use both at the same time, which is what my friend was doing.

Do a search on "limited vision reader magnifier" and see what comes up. A couple of pages I found are: http://www.freedomscientific.com/fs_products/software.asp
http://www.otal.umd.edu/UUPractice/vision/

TenTonJim

6:50 pm on Dec 10, 2002 (gmt 0)

10+ Year Member



Also, pt will stay static in the browser font size selection of IE (not NS6+ or Mozilla).

px overrides the OS settings...

JimS.

imaputz

11:27 pm on Dec 10, 2002 (gmt 0)

10+ Year Member



thx zollerwagner. I've been looking for other screenreaders to try out.

toadhall

5:58 am on Dec 16, 2002 (gmt 0)

10+ Year Member



I've written a PHP thingy to allow choice of 'small' 'medium' 'large' font sizes on the page. Resets pixel sizes in CSS. Always wanted to do that, and the weather was so rotten today, I did.

Just Sticky me if you'd like the code...

T :)

zollerwagner

6:23 am on Dec 16, 2002 (gmt 0)

10+ Year Member



That's pretty concise, Toadhall! I'm impressed the task can been done so easily.

I wonder if it was necessary to put this:
$fontsize='medium';
in the css declaration? Couldn't you leave it out and thus shorten the script even further?

p {font:<?if(!$fontsize){$fontsize='medium';echo$size;}else{echo($fontsize=='large'?$size+2:$size-2);}?>px ....

Thanks for sharing your creation with us.
Art

toadhall

6:44 am on Dec 16, 2002 (gmt 0)

10+ Year Member



Thanks zollerwagner

> I wonder if it was necessary...

You're right, it's not necessary for the functioning of the script, but I wanted to return an indication of which size the viewer had chosen, that is:

Font size = <?=$fontsize;?><br>

Without it the 'medium' size would show 'Font size = *blank*'. Try it. :)

I first attempted writing this in javascript. Was much easier in PHP.

zollerwagner

7:03 am on Dec 16, 2002 (gmt 0)

10+ Year Member



Oops, yes, I see it now. Thanks for pointing that out.

Nice job!
Art

toadhall

7:20 pm on Dec 16, 2002 (gmt 0)

10+ Year Member



I've finished two javascript versions. One that uses code specific to IE, and another that works elsewhere (guess which one I like). The second, universal version uses an external .js file that extracts arguments from a query string.

Sticky me if you'd like to see the code.

T

zollerwagner

7:47 pm on Dec 16, 2002 (gmt 0)

10+ Year Member



Is there any chance you could annotate the .js file to help me understand what you're doing there?

toadhall

9:45 pm on Dec 16, 2002 (gmt 0)

10+ Year Member



Check your Sticky mail. :)