Div Class or div ID and Ranking in Google

Hello,

Firstly I am unsure the difference between a DIV CLASS and and DIV ID. When should I use each DIV type?

Secondly, I think I am using DIV ID when I should be using DIV CLASS. Will this affect the ranking in Google?

Does Google look for correct CSS?

Thanks.

Matt.

I’m sure someone can explain the difference between class and id better than me, but essential, use class unless it needs to be id.

As far as Google is concerned, I’m sure you’ve been directed to Google’s guidelines before (if not I can hunt them out for you) but what does it say about CSS there?

when does it need to be an id? I am currently using id only. I only use class for text style. Is this wrong?

And no, I have not seen CSS guidelines from Google.

ID means identity. It is used to unambiguously identify an element in the html, therefore each must be unique to the page.

Class on the other hand specifies a classification for an element, classes are re-usable, so you may have the same class on many elements within a page.

Probably not. The only problem I see is the misuse of ID, commonly people using the same ID multiple times on a page. This is invalid html, I’m not sure if, or to what extent this affects ranking, but it does elude to poor quality coding.

I don’t know about any SEO differences, I imagine you’re over-thinking this if you’re more concerned about SEO than semantics and maintainability.

I used to use id back when it was easier for JavaScript to use getElementById() but now JavaScript has ways to select elements in other ways.
IMHO a main reason for avoiding id in preference for class is because in CSS id has precedence over class and can cause problems when styling a page.

4 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.