Pure space directly inside div ignored, but pure space directlyinside span honored

Discussion in 'HTML' started by liketofindoutwhy@gmail.com, Mar 29, 2008.

  1. Guest

    i found that there is a rule regarding "pure space" directly inside a
    block element or directly inside an inline element. For the following
    example, in compliance strict mode:

    <body>

    <div>

    hello
    world

    </div>

    <div>

    <img src="pic.jpg">
    <img src="pic.jpg">

    </div>

    </body>

    there are tons of spaces after the first <div>, and they are the
    newline and space characters. But none is honored. None is rendered.
    (I think they are stored in the DOM tree, but it is just not rendered
    on the displayed, because they are directly inside a block element).
    Also between the two <div></div> ... <div></div> there are tons of
    spaces in the "..." region, but none is rendered. And the same goes
    for spaces before the first <img> tag and after the second <img> tag.
    (i tested using a body width of 300px, with two images of width 150px,
    and the spaces after the second <img> is not causing any vertical
    enlargement of div area if i set a visible border on the div. to see
    both images on the same line in this case, the <img> tags will need to
    be side by side, without any space or newline in between)

    So the rule is, any pure space directly inside a block element is
    ignored when the browser displays it, it would seem.

    Now, when the anonymous inline begins, such as in the case of "hello"
    and then "world", and in the case of the first <img> and the second
    one, since it begins an anonymous inline element, any pure space in
    between will be rendered.

    That goes for newline, indentation by tab or space characters, etc.

    And that's why we can freely indent the <div> with lots of spaces and
    newline without any side effect.

    This seems like the rule, applicable on IE7, Firefox 2, and Safari 3.
    This being the general rule it seems, does the HTML spec, CSS
    Definitive Guide, or any formal doc actually say something about this?
     
    , Mar 29, 2008
    #1
    1. Advertising

  2. John Hosking Guest

    wrote [both here and in c.i.w.a.s]:

    Folks who multi-post tend to have more trouble getting help than other
    folks. (Today's your lucky day. ;-) ) Many in Usenet automatically
    ignore posts from those using GoogleGroups, so that's already a strike
    against you. Don't make it hard on yourself to get help. In any case,
    your post is clearly out of place in c.i.w.a.s, as it has nothing to do
    with stylesheets.

    > i found that there is a rule regarding "pure space" directly inside a
    > block element or directly inside an inline element. For the following
    > example, in compliance strict mode:


    I don't know what "compliance strict mode" is, but take a look at
    http://www.w3.org/TR/html401/struct/text.html#h-9.1 and see if it helps
    you. You may be especially interested in the sentence,

    "In particular, user agents should collapse input white space sequences
    when producing output inter-word space."

    [much empirical observation and guesswork snipped]

    >
    > This seems like the rule, applicable on IE7, Firefox 2, and Safari 3.
    > This being the general rule it seems, does the HTML spec, CSS
    > Definitive Guide, or any formal doc actually say something about this?


    Did you not find anything when you looked? What's the CSS Definitive
    Guide, and what authority does it have? It sounds less like a "formal
    doc" and more like "some book somebody wrote."


    --
    John
    Read about the UIP: http://improve-usenet.org/
    Eric Meyer: He's just this guy, you know?
     
    John Hosking, Mar 29, 2008
    #2
    1. Advertising

  3. Ben C Guest

    Re: Pure space directly inside div ignored, but pure space directly inside span honored

    On 2008-03-29, John Hosking <> wrote:
    > wrote [both here and in c.i.w.a.s]:
    >
    > Folks who multi-post tend to have more trouble getting help than other
    > folks. (Today's your lucky day. ;-) ) Many in Usenet automatically
    > ignore posts from those using GoogleGroups, so that's already a strike
    > against you. Don't make it hard on yourself to get help. In any case,
    > your post is clearly out of place in c.i.w.a.s, as it has nothing to do
    > with stylesheets.


    Whitespace collapsing is defined in CSS (as well as in HTML).

    >> i found that there is a rule regarding "pure space" directly inside a
    >> block element or directly inside an inline element. For the following
    >> example, in compliance strict mode:

    >
    > I don't know what "compliance strict mode" is, but take a look at
    > http://www.w3.org/TR/html401/struct/text.html#h-9.1 and see if it helps
    > you. You may be especially interested in the sentence,
    >
    > "In particular, user agents should collapse input white space sequences
    > when producing output inter-word space."

    [...]
     
    Ben C, Mar 29, 2008
    #3
  4. Guest

    On Mar 29, 3:03 am, Ben C <> wrote:
    > On 2008-03-29, John Hosking <> wrote:
    >
    > > "In particular, user agents should collapse input white space sequences
    > > when producing output inter-word space."



    sigh... it is not "inter word" space... it is outer...

    <div> hello world </div>

    the spaces before hello is not inter-word. AND IT IS NOT COLLAPSED.
    IT IS TOTALLY IGNORED.
     
    , Mar 29, 2008
    #4
  5. Ben C Guest

    Re: Pure space directly inside div ignored, but pure space directly inside span honored

    On 2008-03-29, <> wrote:
    > On Mar 29, 3:03 am, Ben C <> wrote:
    >> On 2008-03-29, John Hosking <> wrote:
    >>
    >> > "In particular, user agents should collapse input white space sequences
    >> > when producing output inter-word space."

    >
    >
    > sigh... it is not "inter word" space... it is outer...
    >
    ><div> hello world </div>
    >
    > the spaces before hello is not inter-word. AND IT IS NOT COLLAPSED.
    > IT IS TOTALLY IGNORED.


    See CSS 2.1 16.6.1 second section, item 1, "[...] a space at the
    beginning of a line [...] is removed"

    So you're both wrong. It isn't collapsed or ignored, it's REMOVED.
     
    Ben C, Mar 29, 2008
    #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. Fulio Open

    Can span include span?

    Fulio Open, Jun 26, 2009, in forum: HTML
    Replies:
    5
    Views:
    560
    dorayme
    Jun 26, 2009
  2. Stéphane Klein
    Replies:
    2
    Views:
    1,807
    John Nagle
    Mar 30, 2010
  3. Dwayne Madsen

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

    Dwayne Madsen, Jun 1, 2005, in forum: Javascript
    Replies:
    1
    Views:
    208
    David Dorward
    Jun 1, 2005
  4. Richard Lionheart
    Replies:
    8
    Views:
    139
    Thomas 'PointedEars' Lahn
    Mar 16, 2006
  5. 123Jim
    Replies:
    0
    Views:
    148
    123Jim
    May 16, 2011
Loading...

Share This Page