Div is short for divisions, structural building blocks within the code.
<DIV>!
A <div> element is most likely to be styled and positioned using CSS. Making a DIV relate to CSS is easy. Here's an example of it linking to the CSS via its ID, or the title that the CSS looks for. Of course, you'll need the HTML document to use an external stylesheet, but I think doing that is pretty self-explanatory. If anything, use google.
<DIV id="div1">
That links it to the appropriate "style.css" section. The CSS code would be something like this:
#div1 { style goes here; }
Styles are the visual and structural changes made to a standard DIV element. For instance,
#leftend { width: 16px; height: 24px; position: absolute; left: 10px; top: 0px; }is a bit of code taken from the CSS of my site, prime cencored revora on his forum , actually. Let's break it down.
Width and Height specify how many pixels wide, and how many tall the DIV element is.
Position: Absolute; specifies that it is being positioned relevant to the browser window itself
Left:, Top:, Right;, and Bottom; all specify how many pixels away from the edges the DIV is. If you use none it will center. Each location of absolute positioning will automatically position it to the side specified, and how many pixels you put as the value will shift it over. So, my DIV style shown above would position it at the top left, but away from the left side 10 pixels.
If you were wondering what browsers support DIV tags, the answer is any browser which is Standard XHTML compliant. If you are confused as to what that means, here is a list of the standard browsers which support standard XHTML.
* Netscape 2, 3, 4, 6, 7
* Mozilla 1
* Firefox 1
* Internet Explorer 3, 4, 5, 6
* Opera 3, 4, 5, 6, 7, 8
* Safari 1
* WebTV/MSN TV
* AvantGo Palm OS
* AvantGo Windows CE
(Source: http://webdesign.abo...bltags_div.htm)
Thats the basic lowdown of DIV elements. One advantage is that DIVs load each picture/text seperately, so you dont have to wait for it all to be rendered before it is displayed. DIV's are fast, and they are supported by every modern web browser.
If something is off by 1 pixel, ONLY in Internet Explorer, or any other browsers that use the MSHTML rendering engine, don't be alarmed. This happens when you use absolute positioning, so here's how to fix it:
Make a new attribute, from the direction of the div having the problem. To make a 1 pixel IE only change, add an underscore before an IE only attribute, and add the 1 pixel difference that is needed, like so:
right: 10px; _right: 9px;The 2nd attribute overrides the first, but only in IE.
Absolute positioning can be a pain in the ass to work with, but it pays off. IE has problems with it, and the Underscore trick is a little hack which can only be read by a browser that uses the MSHTML rendering engine. It can be used for any tag meant to be IE-only.
Have fun, and if you have any questions, please feel free to PM me them.
Edited by Legion, 18 July 2006 - 06:28 PM.