|
Post by Tominator on Nov 26, 2005 23:45:46 GMT
Hello all. I apologize if this is placed in the wrong board. Anyhow, I actually began coding (HTML) about a half a year back, and thought I had the grasp. Recently, I have been striving to advance in coding. Now, I use w3schools for my tutorials and information on different types of code. I figured that I would go through the HTML tutorial once more.
Granted, I read a lot I didn't know. Probobly because I was too much of a lazy ass to learn the correct way, so I viewed it's source all the time. Anyways, one thing that wasn't mentioned too much in that tutorial was the <div> Tag.
What is it? What does it do? Please help me out, hehe. I see it used in a lot of HTML codes, but never really understood it's purpose.
The Tominator
|
|
chemdude
Full Member
2B || !2B
Posts: 228
|
Post by chemdude on Nov 27, 2005 0:01:59 GMT
Click. The div tag can give certain attributes (like id) for block-level code and is really useful for collapsing/expanding paragraphs, css, and other stuff. It's commonly used to give block-level code an identity.
|
|
|
Post by acoolie530 on Nov 27, 2005 0:17:27 GMT
The div tag stands for a division of the page and that literally is what it is.
It is commonly used for CSS driven layouts. Divs are used to make the source look much cleaner, the page load faster, and the page to work in many browsers.
|
|
|
Post by Tominator on Nov 27, 2005 0:19:34 GMT
Thanks everyone. I definately do have a much clearer view at the <div> tag now. Thanks again!
|
|
|
Post by california on Nov 27, 2005 23:24:55 GMT
|
|
|
Post by Tominator on Nov 28, 2005 0:07:44 GMT
Thanks. Does this mean, then, that the selector class applied becomes the class in the Div tag? For example:
<html> <head> <style type="text/css"> div.test { property:value } </style> </head> <body> <div class/id="test">bla</div> </body> </html>
Would that be correct?
|
|
|
Post by crazynarutard on Nov 28, 2005 0:15:48 GMT
<div class="test">
|
|
|
Post by Tominator on Nov 28, 2005 0:21:48 GMT
Couldn't ID work as well? I put the slash to show that it could be either one...that is not the case?
|
|
|
Post by crazynarutard on Nov 28, 2005 0:23:37 GMT
if you want to use ID: #font{ text-align:center; } <font id="font">omg </font>ID is unique though, so you can only use it once
|
|
chemdude
Full Member
2B || !2B
Posts: 228
|
Post by chemdude on Nov 28, 2005 1:53:24 GMT
Classes use a . for CSS, while IDs use a #
Like Crazy_J said though, IDs are unique and can be used only once.
There is also something called a "name", but let's not get into that.....unless you really want to know of course though.....
|
|
|
Post by Tominator on Nov 28, 2005 2:29:11 GMT
Not quite yet. Knowing that difference is going to help now. However, when you say "can only be used once" what exactly does this mean? Also, for the id's, is the selector the entire "#font" or does something come before it, like the class div.test. Is it "p#font?" Sorry for the inconvenience...
|
|
|
Post by crazynarutard on Nov 28, 2005 2:44:33 GMT
You can only use it once, meaning the value of the id attribute can only be used once. #centerformozillaonly{ margin:auto; }
if we added that to a div: <div id="centerformozillaonly">
It could only be used for that div tag, you can't use it for anything else anymore. So that explains your other question too
|
|
|
Post by california on Nov 28, 2005 4:32:18 GMT
You can use div#centermozilla as far as I know, but since there can only be one tag with the ID the "div" isn't necessary.
As for names, you can only use those for form elements in the latest w3c specs.
|
|
|
Post by acoolie530 on Nov 28, 2005 12:40:15 GMT
You can also use div[name="myDiv"] {} with <div name="myDiv"></div>
|
|
|
Post by Tominator on Nov 28, 2005 19:32:03 GMT
Thanks, I most certainly understand the differences now. Thanks to everyone who helped! Expect to see me in the near future.
|
|
|
Post by california on Dec 4, 2005 23:32:27 GMT
|
|
|
Post by acoolie530 on Dec 4, 2005 23:40:11 GMT
Well, div[id="myDiv"] works fine too
|
|
|
Post by california on Dec 5, 2005 3:15:59 GMT
Does that work in IE though? I could have sworn that was moz/gecko proprietary.
|
|
|
Post by acoolie530 on Dec 5, 2005 3:35:05 GMT
It works in IE. The only problem with it is #myDiv overrules it.
|
|
|
Post by Charles Stover on Dec 17, 2005 23:42:17 GMT
Well, there's a lot of reading, here, so I didn't do it. The <div> tag is, if you ask me, the most useful tag I've ever used. Most people don't use it, but instead use <table>, which is the most incorrect thing you could do. <table> loads slower and is only meant for tabular data, such as: Name | Posts | Rank | GAMEchief | 15 | Newbie | SegaDragon | 10 | Newbie |
Using tables for simple things like alignment, borders, or just arranging things is absolutely wrong and is what is seen on too many websites.
|
|