Ok, so I posted this up in another thread but was instructed to post it up as a separate questions

I am fairly new to css, so the conversation over DIV and CLASS interests me. I have built a site using wordpress which has allowed multiple ID’s. I am interested if there really is anything wrong with this? For example, this code displays four boxes in two columns, two rows within the container…

<div id="container">
    <div id="sub_container"
    </div>
    <div id="sub_container"
    </div>
    <div id="sub_container"
    </div>
    <div id="sub_container"
</div>

If I have specific styling that is different to the WP theme, obviously then it can be applied to the div or the class?

So in the case above I might have

#sub_container {background: #ffffff; position: relative; float: left;}

So I want to figure is this OK? If not, what is the benefit of having the sub container as a class rather than a div? I get the ‘unique’ argument, but if this works fine, why not use it?

In my code I have used classes for some headings and sections where I want specific formatting that varies from the built in formatting, but that’s about it..

..I figure I would use class if I wanted to apply different styles to the sub_container div? e.g. might want the second one to have red fonts, or have the boxes a different size on another page etc etc?

Read more here: Situations to use DIV over CLASS


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, ,

Wordpress related questions and answers: