10

I am a big fan of minifying everything whenever possible. It is a sin for me to don't do this.

However, I recently read that one of the thousands tips to boost your website rank on search engines was to:

give you content context with good class and id name in your HTML

[source]

I always change id and class names to one or two character length...

Is not that I don't believe what that guy said, but I really need some confirmation on this. For me it doesn't make sense why would that matter.

  • Is that point correct?
  • (in case it is) Why?
1

3 Answers 3

9

I wouldn't worry about ID and class names. Although the most popular ID names did affect new HTML5 tags names (header, footer, etc) and may help non HTML5 sites show distinct sections of their pages, I wouldn't go so far as to say including keywords in them affect rankings. I would be sure to use proper HTML tags and microformats, however. We know as a fact that search engines use those as rankings factors or at the very least that they can affect how search engines display your content in their search results which can affect your click through rate.

1
  • Is there any document which says it doesn't affect SEO ranking? I have a doubt. Because if I keep my main menu class is "navingation-bar" then certainly, Google can understand it, but if I keep my main menu class as "lorem-ipsum-sit-amet" then it is difficult to figure out. I am searching for a document for the best practices in HTML class name for SEO. Incase if anyone knows then please paste the link. Thanks in advance. Commented Dec 18, 2017 at 7:31
5

No, it is not correct and unfortunately that is one of the lower quality answers to that question that somehow got upvotes. I edited it to remove that line.

Class names and ID names in HTML make no difference to SEO. One exception is the case of microformats where search engines parse them, and may display certain extra snippets in search results.

There is no need to try and "minify" your HTML. Make sure the server is sending the content gzipped as that makes a big difference.

Note that many of the answers to that question are not things that would directly improve search rankings, most are about site visibility and promotion, which are long-term, indirect ranking factors.

1
  • While this is probably true for the search engines people are concerned about it should be mentioned that search engines are all just algorithms and could be based off of anything. My search engine orders results based on the brevity of class and id names so if you are looking to improve SEO on my search engine minifying would be the best optimization possible.
    – J.Money
    Commented Sep 8, 2015 at 17:29
1

I don't think ID's nor classes matter SEO wise.

However: why are you changing id and class names to 1 or 2 characters? What do you gain from it? If you are doing it for performance, don't do it. Minifying them only gives you a very tiny gain. And the only thing you got is unreadable, unrecognizable stuff.

5
  • I keep a copy of the unminified version
    – ajax333221
    Commented Feb 5, 2012 at 0:29
  • But why do you do it in the first place I'm wondering?
    – PeeHaa
    Commented Feb 5, 2012 at 0:31
  • lower file-size = lower time to download. classes and IDs appear around 100 times on html+css, so if I can reduce 5 chars * 100 times... I save 500 chars
    – ajax333221
    Commented Feb 5, 2012 at 0:33
  • @ajax sounds like micro-optimization to me - consider that you'll save a few hundred bytes by this, while every JPG will cost you hundreds of times that. Plus proper gzip compression will take care of those patterns anyway. But I guess there's no harm in doing this, either
    – Pekka
    Commented Feb 5, 2012 at 0:39
  • @ajax333221 ^^ It doesn't just sound like it. It's just is :-)
    – PeeHaa
    Commented Feb 5, 2012 at 1:23

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.