Results 1 to 2 of 2

Thread: HTML whitespace parsing rule?

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default HTML whitespace parsing rule?

    That or is there a link I could look at to read more about it?

    I notice that multiple spaces are often condensed down to just one. I have a PCRE code that deals with this as well as CRLFs , but I never did learn what the rules are for HTML parsing spaces the way it does .

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The actual implementation of parsing white space varies slightly with different browsers. Generally, if we are talking about the space and/or tab character itself, multiple spaces and/or tabs are condensed into one space. Line breaks and/or the position within a tag where white space falls can sometimes produce a space where no tab and/or space character exists in the code and sometimes can result in existing tabs and/or spaces not getting rendered at all. For instance, a line break between to inline elements almost always results in a space between them. This behavior, and the treatment of the <pre> tag, and white-space css style values are where the browsers really diverge.

    Common sense (not trying to do anything too special) and neat source code usually will result in consistent behavior across browsers. When this breaks down, a way can almost always be found to get the behavior to be consistent.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •