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

D

Don Vaillancourt

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>
 
R

Richard Cornford

Dietmar said:
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.
 
S

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.
 
R

Richard Cornford

Stanimir said:
/Richard Cornford/:

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.
 
S

Stanimir Stamenkov

/Stanimir Stamenkov/:
/Richard Cornford/:


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.
 
S

Stanimir Stamenkov

/Richard Cornford/:
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. :)
 
R

Richard Cornford

Stanimir said:
/Richard Cornford/:

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.
 
D

Dietmar Meier

Richard said:
offsetHeight is a Microsoft proprietary property
of elements (introduced in IE 4) that has been adopted by other
browsers

Whoa, yes.

ciao, dhgm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top