Tell me more ×
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

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

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

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

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

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

share|improve this answer

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

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

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.
{"cc_re__cc_re__cc_by_sa_3_0": ["f=\"http://area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"http://careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &copy; 2013 stack exchange inc; \r\n                user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc-wiki</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"footer-flair\">\r\n                <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" class=\"cc-wiki-link\"></a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2013.5.24.702\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\"", "\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &copy; 2013 stack exchange inc; \r\n                user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc-wiki</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"footer-flair\">\r\n                <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" class=\"cc-wiki-link\"></a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2013.5.24.702\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Webmasters Stack Exchange works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </noscript>\r\n    <script type=\"text/javascript\">var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-5620270-24']);\r\n        _gaq.push(['_setDoma"], "copyright__copyright__copyright": ["d 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.\n\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}