By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

How to tell height of div where height is not set?

P: n/a
Is there a way to determine the height of the following div.

<div style="width:200px;">
This is content.<br>
Inside a div that
will expand vertically
as more content is displayed.
</div>
Jul 23 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Don Vaillancourt wrote:
Is there a way to determine the height of the following div.


In DOM compatible UAs, Element.offsetHeight is your friend.

ciao, dhgm
Jul 23 '05 #2

P: n/a
Dietmar Meier wrote:
Don Vaillancourt wrote:
Is there a way to determine the height of the following div.


In DOM compatible UAs, Element.offsetHeight is your friend.


It doesn't seem reasonable to describe a UA supporting offsetHeight as
'DOM compatible' as offsetHeight is a Microsoft proprietary property of
elements (introduced in IE 4) that has been adopted by other browsers
(and is very useful) and it is not part of current (Level 2) DOM
specifications. There is at least one DOM compatible (Level 1 in that
case) browser that does not implement any source of element size and
position information.

Richard.
Jul 23 '05 #3

P: n/a
/Richard Cornford/:
Dietmar Meier wrote:
Don Vaillancourt wrote:
Is there a way to determine the height of the following div.


In DOM compatible UAs, Element.offsetHeight is your friend.


It doesn't seem reasonable to describe a UA supporting offsetHeight as
'DOM compatible' as offsetHeight is a Microsoft proprietary property of
elements (introduced in IE 4) that has been adopted by other browsers
(and is very useful) and it is not part of current (Level 2) DOM
specifications.


Hm, isn't 'ViewCSS.getComputedStyle' part of the DOM Level 2 Style
specification, meant for just that? The core DOM interfaces aren't
meant to deal with visual presentation issues, anyway.

--
Stanimir
Jul 23 '05 #4

P: n/a
Stanimir Stamenkov wrote:
/Richard Cornford/:
Dietmar Meier wrote:
Don Vaillancourt wrote:

Is there a way to determine the height of the following div.

In DOM compatible UAs, Element.offsetHeight is your friend.


It doesn't seem reasonable to describe a UA supporting offsetHeight
as 'DOM compatible' as offsetHeight is a Microsoft proprietary
property of elements (introduced in IE 4) that has been adopted by
other browsers (and is very useful) and it is not part of current
(Level 2) DOM specifications.


Hm, isn't 'ViewCSS.getComputedStyle' part of the DOM Level 2 Style
specification, meant for just that? The core DOM interfaces aren't
meant to deal with visual presentation issues, anyway.


And this is relevant to the use of offsetHeight because ... ?

Richard.
Jul 23 '05 #5

P: n/a
/Stanimir Stamenkov/:
/Richard Cornford/:
It doesn't seem reasonable to describe a UA supporting offsetHeight as
'DOM compatible' as offsetHeight is a Microsoft proprietary property of
elements (introduced in IE 4) that has been adopted by other browsers
(and is very useful) and it is not part of current (Level 2) DOM
specifications.


Hm, isn't 'ViewCSS.getComputedStyle' part of the DOM Level 2 Style
specification, meant for just that? The core DOM interfaces aren't meant
to deal with visual presentation issues, anyway.


My bad: the computed is not the same as the actual value
<http://www.w3.org/TR/1998/REC-CSS2-19980512/cascade.html#computed-value>.
But the second sentence still holds. The actual height would be
dependent on the specific style language/layout engine
implementation, which if not CSS based would use different
interfaces to that info.

--
Stanimir
Jul 23 '05 #6

P: n/a
/Richard Cornford/:
Stanimir Stamenkov wrote:
/Richard Cornford/:
It doesn't seem reasonable to describe a UA supporting offsetHeight
as 'DOM compatible' as offsetHeight is a Microsoft proprietary
property of elements (introduced in IE 4) that has been adopted by
other browsers (and is very useful) and it is not part of current
(Level 2) DOM specifications.


Hm, isn't 'ViewCSS.getComputedStyle' part of the DOM Level 2 Style
specification, meant for just that? The core DOM interfaces aren't
meant to deal with visual presentation issues, anyway.


And this is relevant to the use of offsetHeight because ... ?


I was trying to make argument that obtaining the actual height of an
element is part of the DOM Level 2 (although no the core)
specification, but I was wrong. :-)

--
Stanimir
Jul 23 '05 #7

P: n/a
Stanimir Stamenkov wrote:
/Richard Cornford/:
Stanimir Stamenkov wrote:
/Richard Cornford/:

It doesn't seem reasonable to describe a UA supporting
offsetHeight as 'DOM compatible' as offsetHeight is a
Microsoft proprietary property of elements (introduced
in IE 4) that has been adopted by other browsers (and
is very useful) and it is not part of current (Level 2)
DOM specifications.

Hm, isn't 'ViewCSS.getComputedStyle' part of the DOM Level
2 Style specification, meant for just that? The core DOM
interfaces aren't meant to deal with visual presentation
issues, anyway.


And this is relevant to the use of offsetHeight because ... ?


I was trying to make argument that obtaining the actual height of
an element is part of the DOM Level 2 (although no the core)
specification, but I was wrong. :-)


So not relevant to the use of offsetHeight at all. ;)

However, where supported (and tanking variations in implementations
(their completeness and the interpretation of the more ambiguous parts
of the DOM spec) into account) - getComputedStyle - can be used to
acquire information about the height of an element. But it is necessary
to understand how CSS relates to the absolute size of the resulting
element. For example, offsetHeight would include the borders of an
element, while CSS height would specify the height inside the borders
(by CSS specification), not including the (top and bottom) border
widths. Padding, margins, the various display property types, etc, need
to be taken into account when using computed styles to acquire position
and size information.

Richard.
Jul 23 '05 #8

P: n/a
Richard Cornford wrote:
offsetHeight is a Microsoft proprietary property
of elements (introduced in IE 4) that has been adopted by other
browsers


Whoa, yes.

ciao, dhgm
Jul 23 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.