Do tabs, spaces, and line-breaks in HTML markup affect search engine optimization?

7,511

Solution 1

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.

Solution 2

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

Solution 3

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/

Solution 4

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

Solution 5

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:
7,511

Related videos on Youtube

quakkels
Author by

quakkels

Updated on September 18, 2022

Comments

  • quakkels
    quakkels over 1 year

    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.

    • m_pGladiator
      m_pGladiator about 13 years
      You should consider coding the way you want, then minifying for output :)
  • Pekka
    Pekka about 13 years
    Your example is not valid HTML in the first place. This will indeed create problems but it's not really a whitespace problem
  • reblerebel
    reblerebel about 13 years
    @Pekka - Actually, it is valid.
  • Pekka
    Pekka about 13 years
    @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.
  • quakkels
    quakkels about 13 years
    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!!! :-)