1

What's the right way to get the total height of a div element? I'm trying this:

element.outerHeight(true); 

but when I take a screenshot of my page, and measure the height (in pixels) of the element, it seems to be a few pixels taller than what element.outerHeight() is reporting. Is there a different way? I'd like to include all padding/margin in my height.

Thanks

1
  • Are you using any JS library? jQuery? Commented Jul 26, 2010 at 14:54

3 Answers 3

4

If you want to include the padding and border use outerHeight(false), if you want to include padding, border and margin use outerHeight(true) and if you want to include only the height of the element use height().

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, but this is a jQuery function, and the syntax is: $(element).outerHeight(false); See jqapi.com/#p=outerHeight for reference.
2

Use height() method instead:

 $('#element').height(); 

Comments

0
$(window).height(); // returns height of browser viewport $(document).height(); // returns height of HTML document 

1 Comment

Right, but that obviously doesn't answer the question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.