Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make font size independent of screen resolution and monitor size?

I am working on one application in which I want to make font size which is independent of screen resolution and screen size. The font size should be same in all resolutions and all screen sizes. How to do it with javascript and css?

I think Pixel per point is hardware related thing so i am not sure javascript and css have access of it.

I tried many alternatives but couldn't find exact solution.

like image 606
Hiren Dhaduk Avatar asked Apr 26 '13 21:04

Hiren Dhaduk


People also ask

How do I change my screen resolution font and text size on my monitor?

To change your display in Windows, select Start > Settings > Ease of Access > Display. To make only the text on your screen larger, adjust the slider under Make text bigger. To make everything larger, including images and apps, choose an option from the drop-down menu under Make everything bigger.

Does screen resolution affect font size?

Modern computer monitors / screens leave the factory with the screen resolution set at 1024 x 768 pixels or even higher. This is to give the maximum effect for graphics, particularly for playing computer games. However this has the effect of making the text size, and icon size smaller in general use.

How do I increase font size on both monitors?

Click on the “Start Menu,” then “Settings.” Choose “Ease of Access.” In the “Make everything bigger” section, click on “Change the size of apps and text on other displays.” Even though it says “other displays,” the option you choose applies to all screens/monitors.

Why is the font so big on my monitor?

To set your computer's displayed font size to default: Browse to: Start>Control Panel>Appearance and Personalization>Display. Click Smaller - 100% (default). Click Apply.


2 Answers

You can use points (pt), which are based on 1/72 of an inch. This is a unit that traditionally comes from printing. Now, it depends on whether or not the device is configured properly, whether or not this size will be the same from monitor to monitor. It often isn't, but some devices are aware of their physical screen sizes. You can also use inches in, centimeters cm, and millimeters mm.

Use this size, in conjunction with ems, which are relative sizes. That way, the whole site can scale up and down as needed.

body {
    font-size: 12pt;
}
h1 {
    font-size: 2em;
}
p {
    font-size: 1.1em;
}
like image 151
Brad Avatar answered Nov 15 '22 17:11

Brad


There is no good, universal solution. In my opinion, you should just consider that it's not possible. This article was recently published, and suggests a (long-term) solution to that problem. It's long-term because it depends on multiple players (hardware and software manufacturers) to work out.

To quote the author:

It’s ridiculous that we can send robots to Mars yet it’s still virtually impossible to render a glyph on a web page and say with confidence: “If you measure this glyph on your screen with a ruler, it will be exactly 10 millimeters wide.”

like image 30
bfavaretto Avatar answered Nov 15 '22 16:11

bfavaretto