I am building a responsive app targeted to desktop, tablet and mobile phone using HTML and CSS but I am not sure what unit font size should I use that the font fits well in any size screen. What's difference between em, px, pt and percent? What's the best choose for me?
I would like to hear real experiences about it in responsive apps for desktop, tablets and mobile phones
I would be thankful for any help!
You might want to take a look at this article: little link.
Update: Here's a tiny bit of explanation about how this applies in your case:
font-size: 12px;
, you're basically telling the browser that each letter should be 12 pixels high (approximately -- different letters vary in height a bit, but the relative difference is preserved).font-size: 50%;
sets the font size of your element to 50% of the font size of its parent element.1pt
(point) is 1 / 72 of an inch. Setting font-size: 12pt;
sets the height of your characters to 12 / 72 inches (again, different characters differ a bit).1em
is 100%
and 1.5em
is 150%
.So your choice would probably be px
since it would preserve the logical proportions of text size to other sized elements.
Various dimensions are
see kyleschaeffer.com/.... and css-tricks.com/....
But to achieve responsive typo look at https://stackoverflow.com/a/21981859/406659
It seems to me the best will be the incoming rem
and vmin
units as documented here.
To cope with older browser you may want to have some CSS fall backs defined something like:
p, li
{
font-size: 12px;
font-size: 0.75rem;
}
or
p, li
{
font-size: 12px; /* old */
font-size: 1.2vm; /* IE9 */
font-size: 1.2vmin;
}
(credit to Craig Butler)
Try using a mix of px, em, and rem.
Chris Coyier explains in this post that using px for your document, rem for your modules (ie. sections of your page), and em for text elements within your modules, the page will scale cleanly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With