View Full Version : DIVs

09-16-2010, 01:53 AM
I think my problem is with div's but not sure. I am trying to divide the body section of a page into 2 equal columns then style each one individually, but I only want that on one page. What is the best way to do this?

Whats the difference between Class, ID, Tag, and Compound when creating DIV's?


09-16-2010, 04:34 AM
Id is a tag that can only be used once, often reserved for main layout sections ie header content navbar footer. but does not need to be exclusive to these
class is a collection of attributes that can be added to any tag
tag being elements html items such as < Hi> < p> <a>... <div>
so to add a class to them it would become < div class="split">

you can then style that as .split{ position:relative; float:left;width: 50%;}

in answer to your two columns if you use the above class in your styles or attached style sheet
< div class="split">My first column</div>
< div class="split">My second column</div>

that will do it. this is the code but you can do this in design view just cant remember how

09-16-2010, 04:45 AM
to add to that. In CSS you can create a style rule that is based upon a class, ID or tag.

So the rule

div {
color: #F00;

Would style the text in all divs on your page red.

#redDiv {
color: #F00;

Would apply to the text of the div with the ID "redDiv" and

.red {
color: #F00;

Would apply to the text pf any object to which the class rule "red" has been applied.

Notice that tag based rules have no prefix, ID based rules begin with # and class rules begin with a period.

09-17-2010, 01:09 AM
My apologize,I am still very new to this. So if I want to add 2 columns to my body, I can create a div class "left" and Div class "right". Then style them separately and they will only apply to say my Home page and not the bodies of the rest of the pages?

Or would I be better to just add a table 1 row by 2 columns and go from there. What I am trying to re-create is the home page of www.hawkeyeroofing.ca (http://www.hawkeyeroofing.ca). I have the left and right bodies already but what is the best way to create the left side? Any advise would be much appreciated.

Again, I apologize.



09-17-2010, 01:12 AM
yes you can do that . b asically you create default divs ad the class you give them will provide your custom styles

09-17-2010, 05:56 AM
Or would I be better to just add a table 1 row by 2 columns and go from there.

NO!! You are on the right track with divs. Don't use tables for layout.