General discussion regarding <div>s


Hello to everyone!

Sorry for the question, I'm a complete newbie at this.
Could someone please explain, why, in the HTML, each "main" div (with classes ".header", ".nav" and ".main"), contains a sub-div, with the class ".container"?
The class for ".container" specifies some values related to positioning:

.container {
margin: 0 auto;
max-width: 940px;
padding: 0 10px;

Wouldn't have been easier to define header/nav/main as "#id"s and leave ".container" as a class, common to each of the 3 divs, with no extra div?



These classes are bootstrap classes meaning that a bootstrap stylesheet is linked and in that stylesheet these classes are styled(given padding, margin, width ect.)

Now these people use it multiple times in the same website so you will use a class.

id's are unique and meant to be used once
classes can be used multiple times

Thus whenever you see bootstrap example, tutorials, templates you will never see an id.

Why are they in containers ? So that they don't interfere with each others stylings and they don't overlap. Think of the container as a room and your body as the house so in each room it has its own rules, styles ect..

Hope this helps..

It would be best if you read more on Bootrstrap so you understand it..
Do a google search :wink:


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