1,105,208 Community Members

font autoresize to fit screen

Member Avatar
dflor
Newbie Poster
17 posts since Oct 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I've read about, but I don't have any larger monitor to test. So, I'm asking: how can I resize fonts to fit screen?
If I write font-size: 12px/18px, will font be resized according screen resolution?
Or it's better to express font-size in em?
Please give me an answer.

Member Avatar
ingeva
Junior Poster
106 posts since Jul 2008
Reputation Points: 4 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

I've read about, but I don't have any larger monitor to test. So, I'm asking: how can I resize fonts to fit screen?
If I write font-size: 12px/18px, will font be resized according screen resolution?
Or it's better to express font-size in em?

I use "px" only one place: As the font size in the "body" element.
Then when I specify everything else as "em" or "%" I can adjust the whole page with just a few JavaScript statements. When using "%" for objects, it usually means "percentage of the width of the nearest div. With fonts it's the percentage of the font size of the nearest div: 120% == 1.2em).

That way all my pages are auto-adjusted to fit the screen (or rather, the browser window) regardless.

Check my site http://upandforward.com for an example.

This is how I wish the browsers would take care of automatically.

Member Avatar
almostbob
Nearly a Senior Poster
3,381 posts since Jan 2009
Reputation Points: 515 [?]
Q&As Helped to Solve: 424 [?]
Skill Endorsements: 14 [?]
 
0
 

All screen measurements should only be in ems or %
the user sets the screen font to suit their vision on their computer.
change it to something stupid in px, they leave.(all px measurements for fonts are stupid, no offence intended)
Set fonts you want to be larger by 20% to font-size:120%; or font-size:1.2em; smaller to 85%, .85em
let the person viewing the page set the base font.
this screen I am composing on is 1920px high, and 16.8inches
18px text is an invisible grey smudge

Member Avatar
ingeva
Junior Poster
106 posts since Jul 2008
Reputation Points: 4 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

All screen measurements should only be in ems or %
the user sets the screen font to suit their vision on their computer.

You should also take a look at the site I suggested below.
Tell me how it looks on your computer.

Your idea is very close to mine, except I have chosen a solution that's incredibly simple for the user.

Member Avatar
almostbob
Nearly a Senior Poster
3,381 posts since Jan 2009
Reputation Points: 515 [?]
Q&As Helped to Solve: 424 [?]
Skill Endorsements: 14 [?]
 
0
 

went browsing through some old posts to find it

to see how your page looks in other screen sizes OS browsers, submit it to
http://www.browsershots.org
the response is screen images from users with every possible combination

Member Avatar
ccube921
Junior Poster in Training
93 posts since Oct 2008
Reputation Points: 2 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

Ingeva on my laptop your site had scroll bars, is that supposed to happen?

Set everything in em and percentages (except images which you don't declare width and height with %, but, you position with %).

Member Avatar
ingeva
Junior Poster
106 posts since Jul 2008
Reputation Points: 4 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

Ingeva on my laptop your site had scroll bars, is that supposed to happen?

Set everything in em and percentages (except images which you don't declare width and height with %, but, you position with %).

The site also has scrollbars here. I think it's browser dependent, but you don't need to use the horizontal scrollbars since everything is within the window except if you make it very narrow, and nobody would keep it that way because the fonts get too small to be readable.

I use float for positioning horizontally, and absolute positioning in very rare cases.

Member Avatar
MidiMagic
Nearly a Senior Poster
3,404 posts since Jan 2007
Reputation Points: 556 [?]
Q&As Helped to Solve: 215 [?]
Skill Endorsements: 2 [?]
 
0
 

Don't use pixels to declare anything. Using pixels makes the display dependent on the screen resolution of the monitor.

Use points and percentages.

Member Avatar
ingeva
Junior Poster
106 posts since Jul 2008
Reputation Points: 4 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

Don't use pixels to declare anything. Using pixels makes the display dependent on the screen resolution of the monitor.

Use points and percentages.

You have evidently not read what I wrote .... :)

Member Avatar
MidiMagic
Nearly a Senior Poster
3,404 posts since Jan 2007
Reputation Points: 556 [?]
Q&As Helped to Solve: 215 [?]
Skill Endorsements: 2 [?]
 
0
 

You have evidently not read what I wrote .... :)

I read it.

The proper unit of measure for resolution-independent text is the point. It is defined as 1/72 inch on the monitor. The em depends on the font chosen, so it is not a constant.

Member Avatar
ingeva
Junior Poster
106 posts since Jul 2008
Reputation Points: 4 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

I read it.

The proper unit of measure for resolution-independent text is the point. It is defined as 1/72 inch on the monitor. The em depends on the font chosen, so it is not a constant.

That's my point. It shouldn't be a constant, but vary with the size of the window, not with the screen size. Most of us are using some kind of windows-based system these days. Note the "s" in Windows. There can be more than one window on the screen. It's meant to make it possible to adjust the size of windows to fit individual needs. Using points for font size would always render text in the same size. Using ems or percent allows the user to adjust this according to the size of his window.

"is" is one, "should be" is another. There was a fundamental flaw in the way our present windows systems were designed.

Member Avatar
almostbob
Nearly a Senior Poster
3,381 posts since Jan 2009
Reputation Points: 515 [?]
Q&As Helped to Solve: 424 [?]
Skill Endorsements: 14 [?]
 
0
 

I read it.

The proper unit of measure for resolution-independent text is the point. It is defined as 1/72 inch on the monitor. The em depends on the font chosen, so it is not a constant.

Screen fonts are not supposed to be fixed
Fixed text sizes do not conform to W3 standards for accessibility
for the partly blind, moles, voles, the kid with the coke bottle glasses and me,
If some **expletive deleted** sets a fixed text size the page is unreadable, the base font sent on my screen is 45point, relative dimensions ems or % scale around my base font.
fixed fonts in px or pt are jst a fuzzy grey blob.

If it doesnt look good with a different font size, recode the page and do it right.

The most popular page - Google, css xhtml compliant, Only relative font sizes
this site, better than most, has fixed fonts,
-but we coke-bottle glasses, can click a button and change the basefont, so its visible

If ya dont know, and I hope ya dont find out, it sux,
dont speak.
& please start using relative everythings

Member Avatar
MidiMagic
Nearly a Senior Poster
3,404 posts since Jan 2007
Reputation Points: 556 [?]
Q&As Helped to Solve: 215 [?]
Skill Endorsements: 2 [?]
 
0
 

I see what you mean.

I actually use relative font sizes when I can. The only times I use absolute sizes is when I need a font to match the size of an image. Usually it is a BIG font. (what do you do when you need a font size bigger than xx-large?)

I said to use points to make the text a certain size on the monitor, regardless of settings and resolution.

I don't know of anything other than percent that changes with the size of the window. And then, it works horizontally, but not vertically.

I learned something today. There is confusion among authors of CSS materials, because "em" has two different definitions:

- The typesetter's em is the WIDTH of the capital M. It varies with the style of the font. No relative measure was needed for typesetting. The em was used to figure how much text fits on a line.

- The real CSS em is the HEIGHT of the capital M. It is equal to the font size in points.

Unfortunately, the author of the book I learned CSS from looked up em in a dictionary, and used that definition in the book.

The typesetter's em is useless for sizing other items to fonts. It is smaller with a narrower font. Thus, I was misled into believing that the CSS em was useless.

The real CSS em looks very useful. I am going to start using it, now that I know it is not the typesetter's em.

So it seems we have four different things to refer sizes to:

px - the size of the pixel. This depends on the monitor resolution
in, pt - absolute size, assuming a normal size monitor
em - the actual displayed size of the font
% - the size of the container

I normally use percent for the sizes of box objects.

I use inches and points when I need to present a picture and size other objects to it. I do this for the purpose of making sure the detail of the picture is always large enough to be visible.

The only thing I use pixels for is to make sure a border is always visible, but is as small as possible.

I was using points for padding sizes (to separate text from borders), for lack of nothing better. The em is a better measure, now that I know it does not vary with font style.

Member Avatar
ingeva
Junior Poster
106 posts since Jul 2008
Reputation Points: 4 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

I see what you mean.

And you're right about most of what you write here, but percent can be used for font size as well, meaning the size in percent of the font size of the container. Thus, if you set the font size in the container to 1pt (or 1em), you can set
span { font-size:150% }
in the css file to make fonts inside "span" tags 150% bigger.
If you resize the underlining font, the "span" fonts will follow.

So as long as you need a constant relationship between font sizes, this is a simple and convenient way to do it.

Member Avatar
MidiMagic
Nearly a Senior Poster
3,404 posts since Jan 2007
Reputation Points: 556 [?]
Q&As Helped to Solve: 215 [?]
Skill Endorsements: 2 [?]
 
0
 

I tried that today in an h1 tag's style. Firefox would not accept % for a font size (I wanted a double sized font, so I put 200%). It also refused to set a font size in em. The only values that worked were px, pt, and the relative size styles (e.g. large).

Member Avatar
ingeva
Junior Poster
106 posts since Jul 2008
Reputation Points: 4 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

I tried that today in an h1 tag's style. Firefox would not accept % for a font size (I wanted a double sized font, so I put 200%). It also refused to set a font size in em. The only values that worked were px, pt, and the relative size styles (e.g. large).

If that happened you have definitely made a mistake somewhere. Check if it reads your CSS file at all. I bet you it doesn't! :)
Add something like a wild background color. If it can see that it reads the file, so you'll have to look for syntax errors etc.

Make sure that there's a default font size for the <body> element. THAT must be specified in px or pt, or else the browser doesn't know the size of neither em nor percent! :)

Member Avatar
MidiMagic
Nearly a Senior Poster
3,404 posts since Jan 2007
Reputation Points: 556 [?]
Q&As Helped to Solve: 215 [?]
Skill Endorsements: 2 [?]
 
0
 

If that happened you have definitely made a mistake somewhere. Check if it reads your CSS file at all. I bet you it doesn't! :)
Add something like a wild background color. If it can see that it reads the file, so you'll have to look for syntax errors etc.

The rest of the CSS is working. I added it to an existing file.

Make sure that there's a default font size for the <body> element. THAT must be specified in px or pt, or else the browser doesn't know the size of neither em nor percent! :)

That's it.

But I wanted it to use the user's own browser default setting as the value modified. How do I do that?

Member Avatar
ingeva
Junior Poster
106 posts since Jul 2008
Reputation Points: 4 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

But I wanted it to use the user's own browser default setting as the value modified. How do I do that?

By not specifying it in the body tag in the css file.
Everywhere else you can use "em" or "%" for font size, just not in the body tag.

Nothing specified == user's setting. Goes for most things! :)

Member Avatar
MidiMagic
Nearly a Senior Poster
3,404 posts since Jan 2007
Reputation Points: 556 [?]
Q&As Helped to Solve: 215 [?]
Skill Endorsements: 2 [?]
 
0
 

Make sure that there's a default font size for the <body> element. THAT must be specified in px or pt, or else the browser doesn't know the size of neither em nor percent! :)

By not specifying it in the body tag in the css file.
Everywhere else you can use "em" or "%" for font size, just not in the body tag.

One of you says I have to do this, the other says I shouldn't. But it doesn't work if I don't. But if I do, I don't get what I wanted.

Member Avatar
ingeva
Junior Poster
106 posts since Jul 2008
Reputation Points: 4 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

One of you says I have to do this, the other says I shouldn't. But it doesn't work if I don't. But if I do, I don't get what I wanted.

It might be good if you sent us an extract of what you're doing, because I do this with all my sites and it works all the time! :)

Example in css file:

body { font-size:16px; }
p { font-size:150%; }
h1 { font-size:2em; }

Paragraphs will be 24px in size, H1 tags 32px since 1em = 16px.
And so on.
If you change the size of the body font, the other fonts will self-adjust accordingly. Makes editing a whole lot easier.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article