tags:

views:

17

answers:

1

In css text-size, one can specify the size as a percentage. What does this percentage refer to ?

+1  A: 

The percentage refers to the size percentage of the elements parent. I think the default browser font size is 14px, so:


  p{ font-size: 100%; } /* 14px */
  p{ font-size: 85%; } /* 12px */

It starts to get a little more complicated if you have this:


   <style type="text/css">
        div{ font-size: 20px; }
        p{ font-size: 80%; } /* 16px */
   </style>

   <div>
       <p>Some Test</p>
   </div>

Since I set a pixel size for the parent div, and a percentage size for the child paragraph, the child paragraph uses the parent pixel size as the base measurement.

iangraham
"The default text size in browsers is 16px." -http://www.w3schools.com/css/css_font.asp
HaleFx