Forum Moderators: open
The problem I've found is that html elements inherit from their parents the font size, so font size of nested elements is smaller than it should be.
Is there any way to use em's without having to modify all my web pages? (I mean, using a different style with a bigger font size in nested elements, so it would render in the correct size, is not an option, because of the huge amount of code I'd have to rewrite)
Thanks
If you do this, just make sure you don't go overboard. A 10 pixel font that looks great on IE on your PC may be unreadable on a Mac.
The problem I have is that if I change
.text11{FONT-FAMILY:Verdana, Arial, Tahoma, sans-serif;FONT-SIZE:11px} .text11{FONT-FAMILY:Verdana, Arial, Tahoma, sans-serif;FONT-SIZE:1.4em} in my CSS, the body of all my pages look great, and the users can change the font size of their browser if they're visually impaired or simply want to read the page more easily, but the nested elements (tables inside the main table) are to small. The .text11 style is applied twice, one for the main table and another for the nested one (cause is inside the first one), so the font size is reduced twice (1.4em of 1.4em).
Is any way to avoid it?
Leaving aside the question of why you're using nested tables anyway, if I were in your position I would probably give both tables a class, set the font-size of the outer one to 1em and the font-size of the inner one to whatever you think is best. That deals with the cascade because 1*x=x.
The thing that's confusing me here is that 1.4 times 1.4 is 1.96. So, shouldn't the font get BIGGER, not smaller, as it compounds?
Sorry Tedster, I meant ex's, no em's, so you actually get a SMALLER font. The core problem is the same.
I may try your solution. Give the outer table a 1em class a the inner whatever class I want. The problem I think I'd find is that I use nested tables extensively, not only for positioning but also for making thinks like margins of a given width or height. I suppose that if I gave ALL tables a 1em class except the one I want to modify I'll solve the problem.
Thanks
the CSS Official Anthem
You're correct tedster, but
1: it's and old design, so CCS it's not extensively used. I know I should change a lot of things of the site and
2: i'm trying to keep my style sheet as small as possible. Looking at my logs I realized that the style sheet was the most requested file (apart from images like blank.gif ;)), and because of its big size, it took almost 10% of our bandwidth, at present one of the most critical points of our site. I still don't understand why it's downloaded so many times, when the logic thing would be it to be downloaded one time per session or less (if it's loaded from the cache).
I use CSS for all my sites these days and I find getting font sizes that work across platforms, browser versions etc. a nightmare. Ems are the best option I've found so far but they can still vary wildly and IE6 seems way out of sync with previous versions. The inheritence problem is something that I've got used to but it still catches me out sometimes.
I want font sizes that users can adjust if they need to and I don't want to have to produce multiple versions of pages for different browsers. Has anyone found a workable solution?
Not to divert your thread, but...
I still don't understand why it's downloaded so many times, when the logic thing would be it to be downloaded one time per session or less (if it's loaded from the cache)
Check a page which includes your style sheet with a Cachability Checker [ircache.net]. It is likely that the cache-control settings for your CSS file are missing or incorrect.
Jim
Now that I use "em" units only throughout the entire page, I find that the font size remains consistent on all browsers. Of course that's excluding NS4 and IE4, but you can't have everything :)
I've just read something which might solve some of my problems posted by Bobince in another thread:
"em font-sizes in IE4-6/Win are weird... they scale more than they should when you change the 'text size' setting. Which can make text barely readable if you use, say, 0.8em and the user chooses 'smaller' on the text size menu. This problem doesn't happen with percentages, and if the font-size is relative to another non-em font size (eg. a div at 120% containing a paragraph at 0.8em) there is no problem, it is only when the em is relative to the size inherited into the html element this happens.
To sum up: 'em's good, but best when combined with a '%' font-size on the body element. '%'s also good most of the time."
I'll be testing that out.
Basically, it's out of our hands. And rightfully so. The user has control, not us :)
Now that I use "em" units only throughout the entire page, I find that the font size remains consistent on all browsers. Of course that's excluding NS4 and IE4