8

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.

1
  • You should consider coding the way you want, then minifying for output :) Commented Apr 19, 2011 at 22:58

7 Answers 7

10

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.

3

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

1
  • 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!!! :-)
    – yeomandev
    Commented Apr 18, 2011 at 16:57
1

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.

3
  • Your example is not valid HTML in the first place. This will indeed create problems but it's not really a whitespace problem
    – Pekka
    Commented Apr 18, 2011 at 14:48
  • @Pekka - Actually, it is valid.
    – Alohci
    Commented Apr 18, 2011 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
    Commented Apr 18, 2011 at 15:18
1

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/

1

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

0

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

0

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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