#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Posts
    77
    Rep Power
    15

    font size in css


    imho the only way to circumvent the font-resizing by selecting 'large fonts' in Windows' desktop properties dialog is to specify it absolute in px rather than in pt's.

    Can anyone tell me the disadvantages in doing so ?

    thx gerhard
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Seattle WA
    Posts
    863
    Rep Power
    14
    Actually, in CSS a px is a relative unit too, and it is not necessarily the same as a pixel on screen: CSS @w3c. All browsers, except Explorer, also scale pixel settings.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Posts
    77
    Rep Power
    15
    So there is actually no way to keep a font size setting as intended ?

    gerhard
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    173
    Rep Power
    12
    read this: fonts
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2001
    Location
    USA
    Posts
    830
    Rep Power
    14
    MJE, the px unit is relative to the output device, so it is not a relative unit in the same sense that the others are. When the output device is a monitor, do you think there are any browsers that perform the calculation described in the CSS 2 spec?

    My guess is that they use the literal value specified, that is a 1:1 ratio of specified pixels to physical pixels. I tested that in IE 5 and NS 6 (both Win) by setting a font-size in px units and taking screenshots at two different resolution settings, 800x600 and 1280x1024. Neither browser rescaled the pixel values, as should happen according to the CSS 2 spec (assuming the difference in pixel density betweent those two resolution settings was enough to warrant it, which I think it would be).

    Browsers that change the size of text set in px units when the user changes text size settings should not be, because what the user adjusts (the text size setting) does not change the resolution of the output device.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Seattle WA
    Posts
    863
    Rep Power
    14
    Well, a 12px is not necessarily 12 pixels. On a monitor yes, but on a printer for example, the type is much larger than 12 printer dots.

    I would expect that at normal size, a 12px font is 12 pixels high, and no, the CSS spec calculation likely isn't done. Whether or not the browser should adjust text sizes that are set in pixels is really irrelevant, the point is that recent browsers do scale it. I was pointing out that Gerhard's assumption that the font size would be constant is wrong.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2001
    Location
    USA
    Posts
    830
    Rep Power
    14
    Re: monitor / printer -- true indeed. However, that consideration is no reason not to use anything (such as a particular unit) that you need to make your page appear properly in the browser, because that would much more practically be handled by the use of media-specific styles.

    On the contrary, nothing could be more relevent to anyone who is interested in doing standards based development, which is anyone with any sense.

    From a perhaps more obvious common sense standpoint, it's a terrible idea not to have a way in CSS to be able to fix font sizes at will. With that ability, page features (e.g. links in a navigation bar) could often be generated with markup & styles, safe in the realization that your layout won't be destroyed by resized text (particularly if it incorporates images). On the other hand, without that ability the developer would often be forced to implement those features using images. Of course it is not a good idea in general to set your actual content text to a fixed size.

    Yes, I understand completely, it was very helpful of you to let him know that. However, I wanted to express that his logic was correct, clarify the nature of the px unit, and explain that the resizing behavior of browsers that you described in such chilling detail is flawed.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Seattle WA
    Posts
    863
    Rep Power
    14
    Good point, that shold be the way it works, but unfortunately, it isn't.
    Originally posted by JMM
    On the contrary, nothing could be more relevent to anyone who is interested in doing standards based development, which is anyone with any sense.
    Yes, but equally important is the ability to use the code. I realize you're not disagreeing with me, but let's keep it clear that compliant code isn't necessarily good code if it produces undesired effects for some users (as assuming that pixel sizes don't scale can do). I don't, for example, use most CSS2 selectors in my style sheets, because despite them being extremely useful, they leave any one using Explorer out in the cold. My style sheet laden with selectors is proper code, but not too useful (for the time being).

    It's always important to consider both standard and use.
    Last edited by MJEggertson; April 19th, 2003 at 02:36 AM.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Posts
    77
    Rep Power
    15
    Thank you all for enlighting me...

    I think, the best idea is it, of course, to use a layout, which is resistant to font size to a large extend.

    However, especially if using some graphics, too, this is not always possible. In that case I would prefer the method of using the pixel unit rather than e.g. using graphics as navigation.

    Again, thank you,
    Gerhard
  18. #10
  19. Live Xtreme
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Warwickshire UK
    Posts
    32
    Rep Power
    12

    browser resizing can be a good thing...


    I have to write a lot of sites with accessibility in mind, so I need to use font units that the browser can resize. However, it seems most peple say that the pt unit is the relative unit and px is fixed, but px is the only one of the two that ie will resize when you click [view] [text size] ....

    Is there a font unit that will always resize regardless of which browser you are using, and also a unit that will never resize, (even if they appear slightly bigger or smaller, like the mac / pc thing. I can live with that..)
    jon

    anything is possible -- with the right budget!
  20. #11
  21. |<.+#f@#+.&.|
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2002
    Location
    norway
    Posts
    3,009
    Rep Power
    1224
    you can use em
    if you also use em in height/lenght unit on elements, the elements wil scale with the font size,


    most of the time i only use em and/or % ,
    so that the pages are completly scalable,
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    173
    Rep Power
    12
    it's funny that this keeps coming up... but if you go to msn.com you'll notice that they do have fixed font sizes....

    In Ie you can't simply change the size fromt the toolbar.
    don't know about using personalized styles...but that alone tells us something.

    just a passing thought.
  24. #13
  25. Live Xtreme
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Warwickshire UK
    Posts
    32
    Rep Power
    12

    I've been investigating...


    OK, results of a bit of testing for those who are interested.

    Opera :: Can enlarge any text in any unit by zooming in on the page.

    Netscape 7 :: Same as Opera but doesn't do quite as good a job, seems to distort layout a bit on some pages.

    Netscape 4.7 :: Barely makes any changes with px if anything. Works much better with pt units. (But you shouldn't be using this browser any way!!)

    IE 6 :: Makes no changes to pt units, but enlarges px units just fine.

    My conclusion :: px units seem to be a fairly similar size across the board for users who don't change their default font size, (mac users excluded), but can also scale well on the most popular browsers, so I think that px gets my vote.

    Any one else want to contribute findings with other browsers / units??
    jon

    anything is possible -- with the right budget!
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Seattle WA
    Posts
    863
    Rep Power
    14
    Pixel and size (mm, in...) measurements are the most consistent across all platforms, but they scale with screen resolution. Point sizes (pt) are notoriously difficult to work with, because a point on a Mac is way different from a point on a PC of any flavor. Not sure about nix systems.

    I too like the em. They're a little tricky to wrap your head around, but I like them because they scale so well. An em is equal to the computed font-size of an element if it is used to measure a non-font-size width, otherwise it refers to the font size of the parent element if used to set the font-size property. It makes defining inherited size properties real easy (after a little bit of practice), since when done properly, all sizes, from font sizes to element widths, padding, and margins, can be set to scale by changing the base font-size of the root html element.
    Last edited by MJEggertson; April 24th, 2003 at 01:39 PM.

IMN logo majestic logo threadwatch logo seochat tools logo