Jump to content

Still confused on what <div> really does.


Joelthezombie15
 Share

Recommended Posts

A div is a fundamental block element. It is generally used to define a region of a page.

 

http://www.w3schools.com/tags/tag_div.asp

So it (Im going to use an analogy) Its like string, you use to ti time things up and keep then kind of separate from other thing. correct?

Link to comment
Share on other sites

It doesn't DO anything, but it's a way to put many objects in one container. It's mostly used if there isn't any better block-type element to represent the content with. The biggest reason people use divs is to put CSS style to things. A <span> has the same use as a div bit it's "inline" which means it behaves like text rather than like a box.

  • Like 1
Link to comment
Share on other sites

So it (Im going to use an analogy) Its like string, you use to ti time things up and keep then kind of separate from other thing. correct?

 

The best way to understand what a div does is to create a small file and experiment. Such as...

<!DOCTYPE html><html><head><title>tab</title><style>#i1{background-color:#F00;border:3px dotted #000;height:100px;}#i2{background-color:#FF0;border:1px solid #000;}.cl3{background-color:#F0F;border:3px solid #000;}</style></head><body><p>This is some text.</p><div id="i1">  <p>This is some text in a div element.</p></div><div id="i2">  <p>This is some text in a div element.</p></div><div class="cl3">  <p>This is some text in a div element.</p></div></body></html>
Link to comment
Share on other sites

I can get div to work i just dont understand what it does. ive read into it but i cant seem to get a good answer.

I think of Div as a container.

I normally use CSS (#divName) and specify the styling options such as width, height, position and other variables.

 

Then use it in my HTML, <div id="divName">Hello</div>

 

I hope this helps.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...