Forum Moderators: not2easy

Message Too Old, No Replies

Giving the user a font-size option

eg: small, medium, large

         

sniffer

1:02 pm on May 23, 2004 (gmt 0)

10+ Year Member



Hi all

Ive noticed on a few sites lately there's a little trick that allows a user to click, or select the font size of the website. So if you designer has used small, the user can change it just on that site, rather than changing their browser.

how do you do this?

Rambo Tribble

1:12 pm on May 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One way it is done is by using JavaScript to set the body's fontSize attribute. If the other font-size declarations in the document are relative, in other words, if they are set using ems or percentages, they will scale accordingly.

Hester

9:24 am on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can also do it with a range of 'alternate' stylesheets. These are the same as the main sheet you use, but with different font sizes. A lot of browsers allow you to select which stylesheet you want from a menu. You can also add a button for those that don't, which will require JavaScript, as it has to set a cookie to remember the style.

sniffer

11:16 am on May 24, 2004 (gmt 0)

10+ Year Member



oh, ok thank you

i was wondering about a non-javascript option; its a nice feature ands adds value, but isnt totally necessary.

i suppose if you had a small site (say 10 pages), you could make 3 versions of the same page and link to each that uses a different style sheet.. that would be very easy to do, but of course not for a large site

not such an important topic but if you have any other ideas lay them out

thanks!

Hester

8:59 am on May 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i suppose if you had a small site (say 10 pages), you could make 3 versions of the same page and link to each that uses a different style sheet.. that would be very easy to do, but of course not for a large site

No, no, you only need one page. That's the beauty of alternate stylesheets. You can have as many as you like per page. The page loads as normal, but instead of having a fixed style, if the user wishes, they can swap to another style. It happens almost instantly too.

sniffer

2:07 am on May 26, 2004 (gmt 0)

10+ Year Member



"alternate style sheets"

i realise thats what i was looking for... can do a search, now cheers :)