D forums now live!

Nick Sabalausky a at a.a
Wed Feb 15 07:57:55 PST 2012


"Ludovic Silvestre" <ludovic.silvestre at gmail.com> wrote in message 
news:yuepxdfcgjebpkkhjnny at dfeed.kimsufi.thecybershadow.net...
>

I was wondering why the text seemed to be a completely different size on 
different browsers!

> First of all, I recommend to use % for the body's font-size (which you are 
> already using) and the rest should be set with em. That way, the body 
> font-size will be equal to the browser default font size, and the rest of 
> the page will be based on that size.
>

Yes. This.

> Another suggestion is using something like this: 
> http://flexknowlogy.learningfield.org/2008/06/26/setting-font-size-proportional-to-window-size/
>
> Here is an example of the js code:
> function updateFontSize(){
>   msg = document.body.clientWidth;
>
>   var font_math = Math.round( 0.012 * msg * 10 );
>   font_math = font_math < 100 ? 100 : font_math;
>
>   $( "body" ).css({
>       "font-size" : font_math + "%"
>   });
> }
>
> Use that function on page load and page refresh:
> $( window ).resize( ... )
> $( document ).ready( ... )
>

That's not good (and I don't mean because of the JS - it's always possible 
to have non-JS fallback). This is a classic case of narrowly optimizing for 
one specific metric (ie, getting a consistent words-per-line) instead of 
always keeping an eye on the big picture. The problem this creates is that 
font sizes become too uncontrolled:

First of all, shrinking the window *should* re-flow the text, not cause it 
to be too small to read. A shorter line length is *much* better than tiny 
text.

Second, I tried the example:

http://jaredstein.org/resources/stein/js/fonter.html

The text on that page (when I have JS on) is so enormous, that I actually 
have a *very* hard time reading it. Much, much harder than reading really 
long lines. I have to go messing around with my browser's window size just 
to make it readable. I shouldn't have to do that, I've never had to do that 
before, and honestly, who would ever even *think* to do that?

Yea, you *could* clamp the max and min font sizes, but it's really just a 
goofy approach overall. There's a reason that desktop apps never scale by 
messing with font size. Consistent controlled font size just turns out to be 
more important than consistent line length. You're much better off just 
using the CSS "max-width" (or something like that, I forget the exact name) 
and maybe "min-width", both specified in em of course.

In any case, this is one of the reasons I hate the modern web. On the user's 
side, content and view have become completely married together. That's a 
*huge* step backwards. Thanks to a very large effort put into standard file 
formats and general computer-to-computer interop, it used to be that any 
content could be viewed in any program, any UI, any style, any anything the 
*user* wanted. We had achieved a computing golden age! But once things moved 
to the web, that got completely thrown out the window as interface is now 
inseparably *bundled* with content once again (and vice versa - content 
comes inseparably bundled with the interface). While model-view separation 
is popular among webdevs, that separation exists completely on the 
developer's side, not the user's side. Of course in this particular case, 
it's not quite so bad because there's lots of different interfaces to the 
same NNTP server, but still...




More information about the Digitalmars-d-announce mailing list