What's the difference between innerHMTL and outerHTML ?

Discussion in 'Javascript' started by gimme_this_gimme_that, Apr 7, 2008.

  1. Thanks.
    gimme_this_gimme_that, Apr 7, 2008
    1. Advertisements

  2. gimme_this_gimme_that

    Xu, Qian Guest

    <p id="explain">Hello</p>

    innerHTML of element "explain" == Hello
    outerHTML of element "explain" == <p id="explain">Hello</p>
    Xu, Qian, Apr 7, 2008
    1. Advertisements

  3. gimme_this_gimme_that

    Stevo Guest

    Why not just alert the inner and outer HTML of some element and you'll see.
    Stevo, Apr 7, 2008
  4. Thanks Qian
    gimme_this_gimme_that, Apr 7, 2008
  5. gimme_this_gimme_that

    RobG Guest

    You should not assume that the subject of your post is visible when
    the content is read.

    Both innerHTML and outerHTML are proprietary properties introduced by
    IE. innerHTML is a property of a DOM element that represents the HTML
    inside the element, i.e. between the opening and closing tags. It has
    been widely copied, however implementations vary (probably because it
    has no published standard[1]) particularly in how they treat element

    outerHTML is similar to innerHTML, it is an element property that
    includes the opening an closing tags as well as the content. It
    hasn't been as widely copied as innerHTML so it remains more-or-less
    IE only.

    1. That is not to say that a published standard would remove all
    variances, but it would likely reduce them.
    RobG, Apr 8, 2008
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.