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

Discussion in 'Javascript' started by Don Vaillancourt, Jan 28, 2005.

  1. 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>
    Don Vaillancourt, Jan 28, 2005
    #1
    1. Advertising

  2. 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
    Dietmar Meier, Jan 28, 2005
    #2
    1. Advertising

  3. 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.
    Richard Cornford, Jan 28, 2005
    #3
  4. /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
    Stanimir Stamenkov, Jan 30, 2005
    #4
  5. 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.
    Richard Cornford, Jan 30, 2005
    #5
  6. /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
    Stanimir Stamenkov, Jan 30, 2005
    #6
  7. /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
    Stanimir Stamenkov, Jan 30, 2005
    #7
  8. 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.
    Richard Cornford, Jan 30, 2005
    #8
  9. 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
    Dietmar Meier, Jan 31, 2005
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HJ
    Replies:
    5
    Views:
    826
    Jonathan N. Little
    Sep 1, 2006
  2. K Viltersten

    <div ... /> and <div ...></div>

    K Viltersten, Mar 30, 2009, in forum: ASP .Net
    Replies:
    4
    Views:
    708
  3. muggslab

    Div Height = Image height. help

    muggslab, Feb 1, 2010, in forum: HTML and CSS
    Replies:
    1
    Views:
    846
    muggslab
    Feb 1, 2010
  4. Dwayne Madsen

    Q: Div A inside Div B is larger than Div B

    Dwayne Madsen, Jun 1, 2005, in forum: Javascript
    Replies:
    1
    Views:
    165
    David Dorward
    Jun 1, 2005
  5. Replies:
    0
    Views:
    110
Loading...

Share This Page