HTML 4.01 and 5.0 spec: is it somewhat "unspecific" about space characters

Discussion in 'HTML & Website Design' started by winterheat, Mar 29, 2008.

  1. #1
    I have tested the following in IE 7.0.6001.18000, Firefox 2.0.0.13, Safari 3.1, and Opera 9.26

    
    <div>hello world</div>
    <div> hello world </div>
    <div><span> hello world </span></div>
    <div><span>   
           hello world 
    </span></div>
    
    HTML:
    The final rendering in all the modern browsers are the same.

    Think about what the output will be first, before you offer your "expert" opinion. If you cannot say what the exact output will be correctly, don't pretend you are an expert and think it is a beginner's question. It is not.

    And all modern browsers above produce the same result for the following code:

    <h1>hello world</h1>
    <h1> hello world </h1>
    <h1><span> hello world </span></h1>
    
    <p>hello world</p>
    <p> hello world </p>
    <p><span>  hello world  </span></p>
    HTML:
    There is a common rule -- maybe it is de facto -- that is not addressed in the HTML 4.01 or 5.0 spec: any white space BEFORE AND AFTER any concrete content is IGNORED. (or, any space after the beginning tag or before the ending tag is ignored.) NOTE THAT IT IS NOT COLLAPSED. IT IS TOTALLY IGNORED. At first I thought it happens only inside a block element but not inline, but it actually happens in both.

    And that's why designers count on this fact and use
    <div>
        <div>
                ...
        </div>
    <div>
    HTML:
    because some of them know that spaces and newline in front of the second <div> is totally IGNORED. Since it is so widely use, it makes sense that the HTML 5 spec include this rule that everybody relies upon.

    Content is important, but space is important too, as space separates contents and affects final render results.

    I am aware that in http://www.w3.org/TR/html401/struct/text.html
    it is said that

    But the fact that practically all designers rely on the fact that those space is totally ignored and not a single space is rendered, it can make sense to put it into the spec or the recommendation.
     
    winterheat, Mar 29, 2008 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    Just why do you continue to belabor this issue?

    If you want to argue what should or should not be, join the html5wg or the whatwg and participate in the lists. You can offer your suggestions or argue those you don't like. Ian Hickson, the specifications editor for both groups is very good about listening to all contributions and answering same.

    Do keep in mind, the specs are written for the UA vendors and define how they should implement the elements and attribute (html), presentation properties and values (css) and behavior (ECMA script for levels 0 & 1 javascript and W3 DOM specs for javascript 2). Developers have a need to know these things so we can have some expectations of browser behavior.

    Despite an awful lot of work laying down these specs, there are still many cases of undefined behavior. Many times it's because the writers know what they want the browser to do, they just haven't yet figured out how it should be implemented, and leave it to the vendors to try things. Maybe the next revision will include the best implementation. Sometimes the specs say something like do it this way unless it doesn't work for you, then do it the way you think best.

    To get back to this post's question, the W3 recognizes that there is potential for silliness where line breaks are concerned unless the white space immediately after the opening tag and the white space immediately before the closing tag are ignored. That's why they make the suggestion to that effect. Should it be a "must" or "should" condition? Maybe, but it's not really any kind of deal breaker. Spaces used in those positions would fall in the realm of presentation (as you mentioned) and don't belong in your html anyway, or should be authored as the W3 demonstrated in the reference I gave you earlier.

    And, don't even try to define what's expert opinion and what's not. You don't have the necessary understanding yet.

    gary
     
    kk5st, Mar 29, 2008 IP
  3. arwen54

    arwen54 Active Member

    Messages:
    632
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    60
    #3
    I could not have posted better myself, gary...
    bravo!

    I found the OP's posting style to be very condescending so I'm glad someone came in and responded appropriately
    ;)
     
    arwen54, Mar 29, 2008 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #4
    That the OP fails to use the proper terminology also counts against it, much less that it fails to mention the difference between block and inline elements, much less the use of the term 'concrete content' which is just plain gibberish.

    What the specification means on collapsing is that "INTER-WORD" whitespace is collapsed to word-spaces... This has nothing though to do with what you are talking about - the behavior you are seeing is because text inherits behavior from cdata:

    Read up on:
    http://www.w3.org/TR/html401/types.html#type-cdata

    specifically:
    User agents may ignore leading and trailing white space in CDATA attribute values (e.g., " myval " may be interpreted as "myval"). Authors should not declare attribute values with leading or trailing white space.

    if all you are arguing is changing 'may' into 'should' - frankly, there's better stuff to argue about and waste time on.
     
    deathshadow, Mar 29, 2008 IP
  5. winterheat

    winterheat Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I had some questions about something related in another forum, and someone stepped in and said it is meaningless discussion. he was thinking he was the expert and this kind of things is worthless for discussion. That's why i put down before you think it is a beginner's question, make sure you understand it first before you belittle the question. i didn't try to define what expert opinion is really. i was only saying if you don't know the real facts behind it, don't pretend to be an expert and belittle the question. that's it.
     
    winterheat, Mar 29, 2008 IP
  6. winterheat

    winterheat Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    why do you need to say the difference between block and inline elements here? they are the same regarding the fact that spaces after the beginning tag is ignored, and space before the ending tag is ignored.

    concrete content is a lack of a better word for the content after the leading space and before the trailing space.

    even you said you don't like the word "may" in another thread. if the space is not ignored, won't all the webpages out there be rendered differently? so why is clarifying it a waste of time?
     
    winterheat, Mar 29, 2008 IP
  7. winterheat

    winterheat Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    when i post on newsgroup or forums, there always seems to be people who come in and be quite harsh and mean. like go back and read the book. re-read the spec. or RTFM. so this time i am trying to be defensive first. and then people think it is condescending. This doesn't happen in real life. I don't know why it is happening online.
     
    winterheat, Mar 29, 2008 IP
  8. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #8
    An hour and a half prior to your starting this thread, I had addressed exactly the issue, quoting the relevant section from the html4.01 specs.

    That you said
    Makes you appear to be gormless. Then, you continued to flog the lifeless equine.

    I even directed you towards a body that does have the power to make the changes to the wordings you apparently feel are so confusing.

    It is a beginner's question. Make no mistake about that. That's not at issue. What is at issue is your dogged determination that you know more than the people to whom you're directing your question. That has not been established. Once you have gained some experience in understanding the specs, the obviousness of the effect of the specs will become glaringly, well, obvious. It is left to the vendors' discretion, and most will follow the W3's suggestion.

    gary
     
    kk5st, Mar 29, 2008 IP
  9. winterheat

    winterheat Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    i don't know why digitalpoint doesn't send email notification. when i post this topic i wasn't aware you posted to the other thread.

    also, that part of the spec says we cannot rely on
    <a ...> some text </a>
    to have the space rendered.

    it doesn't say the spaces in my post #1 in this thread will all be ignored, and many web design rely on this fact. (depending on the fact that the nested div can have newline and spaces in front of them and they are ignored.)

    you can think it is a beginner's question. but i can say many intermediate people cannot say exact what will be rendered, and why. Even some experience people can't. I can see the question doesn't appeal to "practical people" as they just use hunch and if it doesn't work, they change things to make it work without ask why too much.
     
    winterheat, Mar 29, 2008 IP
  10. Spider-Man

    Spider-Man Banned

    Messages:
    2,684
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Perhaps the most ridiculous question I have heard in my time here. I've got +800 threads that I've posted in - the majority of these threads have more than 1 reply after my comment. Thus, I would receive at least 800 emails, yeah, great thought:rolleyes:

    Ohwait,gotaproblemhere,thewhitespaceistakingoverandyourbrowserhastotallyscrewedupbecauseididntputspacehereandsurelythebrowsershouldofknown iwantedspacebetweenmywords?maybenexttimeiamcodingasiteishouldwriteinlongmonotonoussentenceslikethisbecausebrowsersjustdontworkproperly,dothey?!
    :D
     
    Spider-Man, Mar 30, 2008 IP
    kk5st likes this.
  11. Spider-Man

    Spider-Man Banned

    Messages:
    2,684
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    0
    #11
    @k55st:

    <div class="omgwhyisntthespacesshown">ohwait,gotaproblemhere,thewhitespaceistakingoverandyourbrowserhastotallyscrewedupbecauseididntputspacehereandsurelythebrowsershouldofknown iwantedspacebetweenmywords?</div><div class="ahwaitheretheyare">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maybenexttimeiamcodingasiteishouldwriteinlongmonotonoussentenceslikethisbecausebrowsersjustdontworkproperly,            dothey?!
    Code (markup):
    Better?:p:D haha
     
    Spider-Man, Mar 30, 2008 IP
  12. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I thought that was a setting when you sign up or when you go to your profile. I do get the 800 emails when people answer to threads I've posted in from another forum. I don't care for it but I'm too lazy to change it. : )

    There is a difference between the above-- you'll need to give the span a background colour to see it, and there's no point with the first two because they're just blocks... but I use spaces all the time.

    I make menu items and to have a non-padding space at each end of my list item I have done this: <a href="#"> blah blah </a> instead of <a hred="#">blah blah</a>... I have also noticed that when I want a "clickable background image" I do indeed need to add a space (with the spacebar, I don't use &nb sp with XHTML) to get a clickable area to show in all browsers. <a class="baz" href="#"> </a>
    a.baz {display: block; background: url(blah.gif) 0 0 no-repeat; height: whatever; width: whatever;}
    I made it a block. I put the space in so it's not wholly empty.
    The place I notice the space's use the most is when using a variation of Mike Cherim's (or Eric Meyer's tho I found his much later) CSS popups:
    
    ...in a form...
    <div id="foo">
      <label for="something"><a href="#foo"><span>Textitty text text text must be followed by a space because teh spans, they is inliners </span>label text</a></label>
    <input...>
    </div>
    
    Code (markup):
    The reason the space is needed is when this is viewed with text browsers, the last word of the span will otherwise run into the first word of the label ("they is inlinerslabel text") which the visual browser will not notice (spans are off to the side and appear on hover).
    If the span had been a block, (and if an a or a label could hold a bl0ck), I'd get this with text:
    "they is inliners
    label text"
    So I wouldn't see if there was a space after "inliners" or not.


    So, the space is collapsed often, but don't think it always is (and when it is, it's collapsed to a single whitespace, not zero whitespace). It depends on the element, and what you're doing with it.

    There's lots of stuff I don't know, but find out while building (the clickable a's). So, as a practical person (when I'm not being lazy), if I don't know, I'll either look it up, test it out, or ask a bearded/cloaked/hooded guru (and they usually tell me to look it up anyway : )
     
    Stomme poes, Mar 31, 2008 IP