Click here to Skip to main content
15,902,198 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using System.Drawing.Font to apply css to some html elements. I see that the resultant css has font-size always in px for eg font-size: 16px; . I want the font-size in em for eg font-size: 1em; .

The reason why I want the css in em is because only in this case , change in font-size in browser settings will reflect in any web-page.

Please let me know what needs to be changed to get the font-size css in em.

What I have tried:

I've tried using different GraphicsUnit options like point,pixel etc but the css always remains as px
Posted
Updated 5-Nov-18 2:59am
v3

1 solution

Set your body font size in px, and that's 1em throughout the document. You can then make your font sizes in the rest of your css in em.
 
Share this answer
 
Comments
Richard Deeming 6-Nov-18 9:23am    
Nit-picking: em is relative to the parent element's font size. To match the body font size throughout the document, you'd need to use rem.

Confused About REM and EM? | Jeremy Church[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900