Forum Moderators: not2easy
Where tables are used for layout (urgh!) then % can work well.... but not with positioned DIV elements.
Do any of your have a way around this?
On the other hand - I found that it is wise to use em and % for font sizes and line-heights, because that's where accessability and readability becomes the most critical. Positioning and layout are still done best in px IMO, but I'm not sure everyone agrees about this.
I found that it is wise to use em and % for font sizes and line-heights, because that's where accessability and readability becomes the most critical. Positioning and layout are still done best in px IMO, but I'm not sure everyone agrees about this.
If you set the base font (in the body tag) to 62.8%, it makes 1.0em elsewhere in your document equal to 10px. This makes sizing calculations easy. If you want 12px, its 1.2em. 20px? 2.0em, etc.
In cases where I want a container to expand with the text (like a css nav button) I size width in em's, too, but I always keep the overall page size (wrapper div) explicitly widthed in px.
Maybe I'm just a control freak, but it makes me nervous to think someone could reset their resolution and max out their browser and see a whole paragraph of my text on one line...
Maybe I'm just a control freak, but it makes me nervous to think someone could reset their resolution and max out their browser and see a whole paragraph of my text on one line...
No. This is a normal concern. The real issue of relative v. absolute comes up in two places.
(1)Text size is one area where it is helpful to your users if they can changes the font's size for readability.
(2)Also, you don't want to hard code anyting so it hangs off the side of a 800px width resolution. (I gave up on 640 long ago.)
Other than that, it's not a big deal to set column widths or positions with absolute values.
If you set the base font (in the body tag) to 62.8%, it makes 1.0em elsewhere in your document equal to 10px.
This is true, but also not true. Pixels are absolute, no matter what browser or preferences you use. EM's and % are always relative. That means that f.e in safari, the default text size is smaller than IE, so if you use relative text sizes, they will all be slightly smaller.
If you use opera6 for mac, their default font-size is much larger than IE, so you will see larger fonts there.
In general, it is wise to give the user power to control his or her text size by using relative sizes, but if you are doing very complex layouts based on "print" methodology, it could be wise to use pixels instead.
This is true, but also not true.
It can be difficult, however, to guesstimate exactly how big 1.7em is going to turn out on your page ina given font. I find being able to relate my relative sizing to an absolute size (I have a clear idea in my head of how big 10px or 12px or 30px are) helps me make decisions while writing the stylesheet and minimizes the "peek'n'tweak" stage of style editing.
Although 62.8% isn't a guaranteed equivalent for 10px (and may not even EVER be an equivalent), it IS pretty close and does a decent job of giving me the illusion of control while using relative sizing.
We've found this to be very useful because the containers expand with the text when the user increases font size. This avoids line length problems.
We've tested this in the following browsers and have found no problem with it (we use 62.5% as a base, instead of 62.8% but I don't think there's much difference):
PC/WIN:
IE5
IE5.5
IE6
NS6.2
Mozilla 1.7
Opera 7.5
Firefox 0.9
MAC:
IE5 (OS9)
Safari (OSX)
however, I don't quite get how they differ from %
EM is a size relative to the base font size, even when used for sizing widths or heights on <div> elements. 1.0em = 1 X base font size. 2.0em = 2 X base font size. Etc, with decimal increments in between. (At least that's how I understand it!)