empty P tags and linebreaks

Discussion in 'HTML' started by allie, Nov 2, 2006.

  1. allie

    allie Guest

    I have a problem with inconsistency in IE browser, looking at the
    innerHTML property and the actual contents.

    I used this in a plain HTML page:

    <div contenteditable="true" style="border:solid 1px black"
    onblur="alert(this.innerHTML)">
    </div>

    If you type content with an extra linebreak, and press TAB to leave the
    field, you see for example:
    <p>a</p>
    <p>&nbsp;</p>
    <p>b</p>

    Note that if you use the cursor to browse the DIV, you do NOT see
    actually a space for the second line, there is in fact no space, it is
    a empty line.

    But if you place exactly this same content inside the editable DIV,
    like this:

    <div contenteditable="true" style="border:solid 1px black"
    onblur="alert(this.innerHTML)">
    <p>a</p>
    <p>&nbsp;</p>
    <p>b</p>
    </div>

    and then reload your page, then suddenly you DO see the space. How can
    this be? How can the innerHTML property be different from the actual
    contents ?

    Please help me with this ...
    allie, Nov 2, 2006
    #1
    1. Advertising

  2. allie

    Bergamot Guest

    allie wrote:
    > I have a problem with inconsistency in IE browser, looking at the
    > innerHTML property and the actual contents.


    Why don't you go ask in a Microsoft newsgroup?
    microsoft.public.<something IE-related>

    --
    Berg
    Bergamot, Nov 2, 2006
    #2
    1. Advertising

  3. allie

    CRON Guest

    i had the same problem a while back - i fixed it by using php
    str_replace to just strip all P tags and replace em with <br/>
    CRON, Nov 2, 2006
    #3
  4. allie

    allie Guest

    CRON wrote:
    > i had the same problem a while back - i fixed it by using php
    > str_replace to just strip all P tags and replace em with <br/>


    yes, that's what I also did. I am just wondering, is there something
    else that you can put inside a <p> tag that is like an empty character,
    so that it will be recognized as a line break, not showing anything ?

    So not <p>&nbsp;</p> or <p> </p>, because this still shows a space
    on the empty paragraph. But is there nothing else?

    And bergamot: why is this microsoft related?
    allie, Nov 3, 2006
    #4
  5. allie

    Bergamot Guest

    allie wrote:
    >
    > And bergamot: why is this microsoft related?


    Is your query not specific to *Microsoft* Internet Explorer, and a
    discrepancy with innerHTML, which happens to be proprietary to MS as well?

    It begs the question: Why is this *not* Microsoft related?

    --
    Berg
    Bergamot, Nov 3, 2006
    #5
    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. Stefan Landgraf

    Replacing linebreaks with <br>

    Stefan Landgraf, Aug 19, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    390
    Stefan Landgraf
    Aug 19, 2003
  2. Replies:
    2
    Views:
    592
  3. meltedown

    linebreaks in a text area

    meltedown, Oct 20, 2005, in forum: HTML
    Replies:
    3
    Views:
    511
    Mark Parnell
    Oct 20, 2005
  4. =?ISO-8859-15?Q?Martin_K=F6rner?=

    email: Content-Disposition and linebreaks with long filenames

    =?ISO-8859-15?Q?Martin_K=F6rner?=, Apr 13, 2005, in forum: Python
    Replies:
    2
    Views:
    3,488
    David Bolen
    Apr 19, 2005
  5. Replies:
    11
    Views:
    177
    Anno Siegel
    Apr 12, 2006
Loading...

Share This Page