I was using em
but facing problem in nested items so I decided to use %
as yui suggesting.
To change the size of a font, always use percentages as the units because they render more consistently than ems, and because they allow user-initiated resizing (unlike pixels).
How to convert px into %? like this is for Px to em http://pxtoem.com/
Edit
I found this example is very good but it's only till 24px.
http://yuilibrary.com/yui/docs/cssfonts/cssfonts-size.html
How to calculate size in %
for each size in px
. As a example case, according to this table what will be size in %
for 45px
There are already 2 answers posted, however, they're not correct. Every CSS property that accepts percentage length, defines how these values are being computed. In the terms of font-size
, this is what CSS 2.1 says:
Percentages: refer to inherited font size
It will never depend on window size or so.
How to convert pixels into percents: in most cases, 16px
is the default value for font-size
- this is 100%
. 45px
will thus be 100% * 45px / 16px = 281.25%
.
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