Ivan Jobs
Ivan Jobs

Reputation: 71

How to precisely control font-size on html page?

For example, when I set font-size = 25px with some particular font-family, I want to get a 25px character on html page. But the rendered character is maybe 27px or some value else.

How can I precisely control the exact rendered font size of text?

Upvotes: 1

Views: 350

Answers (1)

ddrace
ddrace

Reputation: 717

There's nothing absolute about font sizes. The pixel size of a typeface is related to the point size, but that relationship can vary, and the point size itself is a relative term, not absolute. The general concept dates back to the days of lead type. You can read more about that here: http://nwalsh.com/comp.fonts/FAQ/cf_8.htm

Point size refers to the height of the font, not the width. It generally refers to the cap-height, but that can vary between fonts, platforms and browsers. And the height can vary between characters in the same font. For example, a capital 'O' will extend slightly below the baseline and above the cap line, while a capital 'H' will be flush with both.

I'm not sure what you're really trying to accomplish, but learning a bit more about typography might give you some good insights.

Upvotes: 1

Related Questions