View Full Version : HTML whitespace parsing rule?
james438
08-04-2007, 08:14 AM
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 :rolleyes: .
jscheuer1
08-04-2007, 08:39 AM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.