Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I am looking for information regarding tabs, spaces, and line-breaks in HTML/XHTML markup and whether it affects SEO.

I have found sources which state that extra white space hurts search engine optimization.

Example:

<div>
    <p>
        Text for a paragraph
    </p>
    <p>
        More text for another paragraph
    </p>
</div>

Should be written like this for SEO:

<div><p>Text for a paragraph</p><p>More text for another paragraph</p></div>

The second version of the code is much harder to maintain so I would far prefer to write code like the first example, but SEO concerns are the top priority.

Does white space negatively affect a site's search engine rankings?

Also, if you have any sources for your answer, please post them or explain your reasoning if you are the source.

share|improve this question

migrated from stackoverflow.com Apr 19 '11 at 4:52

This question came from our site for professional and enthusiast programmers.

    
You should consider coding the way you want, then minifying for output :) –  Mike Hudson Apr 19 '11 at 22:58
add comment

7 Answers

up vote 8 down vote accepted

According to this SEO blog entry, which is transcribing what the head of Google's webspam team Matt Cutts says in the Video, no.

We really don’t care that much. We’re pretty good that anytime we see white space, we’ll separate stuff and we can ignore white space. It really doesn’t cause us a lot of harm either way. The only thing to really pay attention to is where I have seen some really sneaky people who will try to do hidden text or whatever and they’ll start off their HTML with like 60 new lines. So whenever you view source code you’re like, “Man, it’s blank, there is no source. Whoa dude you just blew my mind.” And anybody who is savvy is like, “or I can use the scroll bar and see what’s down here.”

It wouldn't make any sense, either.

share|improve this answer
add comment

So I would far prefer to write code like the first example, but of course, SEO should be considered priority.

No, writing semantic and maintainable mark-up/code is the priority. If you write semantic mark-up then you will likely gain more SEO benefit than any rumours of SEO faeries and voodoo.

But to answer your question, whitespace should not matter. If it is a concern of yours, try writing it in a maintainable fashion and using HTML/CSS/JS minification to reduce filesize and optimise the websites performance, which is taken into account by search engines like Google

share|improve this answer
    
My reasoning is just that I would prefer people to find the site and write horendous code than to write imaculate code and not have anyone find the site. But, the consensus seems to be that whitespace doesn't really matter... so clean, semantic, and maintainable code here I come!!! :-) –  quakkels Apr 18 '11 at 16:57
add comment

I think that extra whitespace in odd places will hurt SEO.

For example,

<img alt="This
is my
alt tag" src="weaksauce.gif"/>

That will probably not result in a proper tagging of the image with some tools.

Also - it is somewhat common to maintain two versions of your HTML - dev and production. You could most definitely strip out all of the whitespace as part of your publishing process if you wanted to. Your maintainability would still be there but your page would be crunched or otherwise transformed as you want it to be.

share|improve this answer
    
Your example is not valid HTML in the first place. This will indeed create problems but it's not really a whitespace problem –  Pekka 웃 Apr 18 '11 at 14:48
    
@Pekka - Actually, it is valid. –  Alohci Apr 18 '11 at 15:17
    
@Alohci oh, indeed it is! I was confusing this with JavaScript, where you can't continue a string beyond a line. I apologize. In that case, +1 to even out the downvote. –  Pekka 웃 Apr 18 '11 at 15:18
add comment

White space isn't a problem for search spiders, they just ignore it. Use a sensible amount to make your code easy to maintain, but don't go overboard. If you're using tonnes of it, it'll increase the file size, but really, it won't make a big difference.

http://buildmysiteforfree.com/seo-tip-27-is-excessive-whitespace-in-the-html-source-bad/

share|improve this answer
add comment

Tabs, Line Breaks, and Spaces, are for readability. It will not affect any SE.

share|improve this answer
add comment

Google doesn't seem to care so I'd stick with keeping your html clean and spacing stuff out: http://www.youtube.com/watch?v=u55Rn1mYgO8&feature=player_embedded

share|improve this answer
add comment

One thing to bear in mind is that even though these won't affect SEO they might affect CTR, e.g. if you have a <br \> within an <h1> or <h2> and Google decides to take this as your page title instead of the one you provide, Google users will only see the text before the <br \> in the SERPS page title.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.