Why do some people have spaces in their CSS ID Tags?
Normally, when you're adding a style tag to a <div>, it's entered like: <div class="tagname"> But lately I've seen sites placing spaces between 'tagnames' example: <div class="header section"> How does this work and what's the purpose of this approach? Also, is it cross-browser compliant?
Public Comments
- Not a good idea to leave unneeded white space in your code. Some may do that for readability purposes, but some browsers do not ignore the extra spaces as they should. Especially if you use spaces in URLs and file/image names. For those it is best to insert the space character entity: "%20" (without quotes). Ron
- It's been my experience that if a person has previous experience in programming, it becomes a habit to do things a certain way. Just like when writing numbers and so forth after taking the higher math classes and drawing a line though the 7's and 0's. The spaces are probably by folks who do not have that experience. Cross browser complaint? I don't know and I wouldn't chance it!
- preference
- Yes I also think it is preferance, not sure if it will make much difference from browser to browser and I don't think it will hinder the seo either..
- The confusion here is that classes are getting set, not IDs. It's perfectly valid to have multiple classes assigned to a single element. It is cross-browser compliant. All Grade A (see source) browsers support multiple classes.
Powered by Yahoo! Answers