Jump to content

Font height

Recommended Posts

Does anyone know how to check the font height assigned to a <div>, or anywhere? I need to know how tall the font is.


Something like that. That doesn't work, of course.

Link to comment
Share on other sites


In javascript a style property is write from CSS property name by removing the '-' and put an uppercase letter on the second word


I have just test this :

The property must be set explicitly on the element by style="font-size:5px"

Example :

.test {font-size:9pt;} // class somewhere
<div id=""youID" class="test"...

don't work and return an empty string

<div id=""youID" style="font-size:9pt;" ....

the same statement return 9pt


Link to comment
Share on other sites

I'm not sure I got it right, but if you want to define a class in css and apply it to a element via js, you should use

document.getElementById('elem').className = 'cname';

And the css class should be

.cname { ... }

LE: just reread the whole thread, I guess I got it wrong ... you mean you already applied the css style and the js property isn't working correctly?

Edited by sadicq
Link to comment
Share on other sites

It's for WPI. .txt is defined in the .css files. Make a <div>, but the content defines with class="txt" later on. I want to see what size the text is of the "txt" class. Maybe thay makes more sense?

The problem is, I need to know BEFORE the text is laid out.

So, what is the font height of the css class "txt" in themes/wpi.css? I want to know as soon as WPI is started.

Link to comment
Share on other sites

Well, I don't think you can do that the easy way ... maybe trying to read the css with js/vb or making a hidden div and apply the class to it (then read the property) could solve the problem ...

Link to comment
Share on other sites

With a CSS style sheet fontSize or fontHeight are not embedded in each element

Navigator read the CSS style sheet then apply style for each element when it display it.

Javascript cannot retrieve any information not embedded in the html document.

In fact first test was not necessary

Only way is to read the CSS file and detect the font attribute of class with a RegExp.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...