| | |
About DIV tags
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Well div elements are generally used with stylesheets. I mean to assgn a particular id or class to the whole division. Stylesheets would recognize it and than format it as what we have defined in the css code. So in most cases div tags have rather associations with stylesheets.
Today CSS is used to make whole page layouts eather than tables.
Today CSS is used to make whole page layouts eather than tables.
You can apply css to tables.
I think the main argument is :
"Tables are doing a job on web layouts that they were never intended for"
However div tags etc. with CSS were made especially for web page layouts:cheesy:
I think the main argument is :
"Tables are doing a job on web layouts that they were never intended for"
However div tags etc. with CSS were made especially for web page layouts:cheesy:
•
•
•
•
However div tags etc. with CSS were made especially for web page layouts
Tables are better for certain elements of layouts; and there's certainly no harm in making tabular data attractive... Table's often aren't the most suitable thing for an entire page's layout... But if they are; it's not really a question of what something was or wasn't designed for, it's a question of how well it does what.
Table's have probably been around since before CSS existed.. they have something of a time-honed reliability that DIV's haven't yet acquired.
Plato forgot the nullahedron..
but, that aside... A div is basically a block of something. It's rectangular, and is comparable with a paragraph. Indeed, if you don't style a div, you might mistake it for a paragraph:
Unlike a paragraph, a div has been designed to be separable from its surrounding markup, by that, I mean it can be moved around. Either laterally, and remaining relative to its siblings (floating) or arbitrarily (positioning). Setting a div to float left:
Floating a div to the left will cause other divs (or text, or anything) logically "after" it in your HTML to be displayed to its right. Floating a div to the right
A div that is not floated to the right will appear in exactly the same place as if the floating elements didn't exist. In this case, it will cause the second floating element to 'clear' the first; but only because both floating elements are the same height.
To 'esacape' from a load of floating elements, you can use the 'clear' CSS property:
Using 'clear' means that no subsequently placed elements will be affected by the floating elements.
You can set the background,foreground,fonts,borders,etc, of a div just like a table cell. You can 'legally' put anything inside a DIV, except things that should be in the head element, or a head or body element.
You can also position divs, relatively or absolutely.
Relative:
The DIV will appear close to where it would 'normally' appear (if it had no style), but it will have moved by 100 pixels to the right.
Absolute:
The DIV will appear aligned to the absolute right of the document, regardless of where the DIV appears in your HTML. It will be aligned by its right edge aswell; and that applies even if the DIV doesn't have a set size, which can be handy.
I will repeat what I said in my last post though. Regarding this "separability" from a surrounding document; in a given a situation this can be useful, or it can be the absolute worst thing to use, and I find that it's rarely a case of 'somehere in-between'. If you want to put two blocks of text next to each other (horizontally), and have them maintain a justified distance to each other regardless of the width of the document; you will probably find a single row table will work better than anything using DIVs.
A DIV is really not much more than an empty block; they have no 'special' properties. With a few exceptions, you can apply any block CSS to any block element, and any text CSS to any block or inline element.
There is, I suppose, one special property for DIVs; the overflow attribute. This doesn't always do what you want it to, but in general, (and providing the DIV is absolutely sized), you can use overflow:hidden, scroll, or auto to respectively; cover up text that would exceed the DIVs absolute size; put scrollbars on the DIV at all times; or put scrollbars on the DIV if the DIV contains text that would otherwise exceed the DIVs absolute size.
Learning and using HTML and CSS appropriately is more important, and will be ultimately more profitable, than learning to design using only DIVs.
HTML and CSS Syntax (Toggle Plain Text)
<div>sentance</div> <div>sentance</div> looks remarkably similar to.. <p>sentance</p> <p>sentance</p>
Unlike a paragraph, a div has been designed to be separable from its surrounding markup, by that, I mean it can be moved around. Either laterally, and remaining relative to its siblings (floating) or arbitrarily (positioning). Setting a div to float left:
<div style="float:left">la</div> will cause it to behave much like a span element. A span element is an inline element, (that is it doesn't break the layout of text it is a part of. Other inline elements include Bold, [I]talic, and [U]nderline tags, or [A]nchors.)Floating a div to the left will cause other divs (or text, or anything) logically "after" it in your HTML to be displayed to its right. Floating a div to the right
<div style="float:right">la</div> will cause anything logically after it in your HTML to be displayed to its left: HTML and CSS Syntax (Toggle Plain Text)
<div style="float:right;"> a complete sentance</div> <div style="float:right;">This will become</div>
A div that is not floated to the right will appear in exactly the same place as if the floating elements didn't exist. In this case, it will cause the second floating element to 'clear' the first; but only because both floating elements are the same height.
HTML and CSS Syntax (Toggle Plain Text)
<div style="float:right;"> a complete sentance</div> <div>breakdown</div> <div style="float:right;">This will become</div>
To 'esacape' from a load of floating elements, you can use the 'clear' CSS property:
HTML and CSS Syntax (Toggle Plain Text)
<div style="float:right;"> a complete sentance</div> <div style="float:left;">This will become</div> <div style="clear:both;> This will be on the next line.</div>
You can set the background,foreground,fonts,borders,etc, of a div just like a table cell. You can 'legally' put anything inside a DIV, except things that should be in the head element, or a head or body element.
You can also position divs, relatively or absolutely.
Relative:
HTML and CSS Syntax (Toggle Plain Text)
<div style="position:relative;left:+100px">anything</div>
Absolute:
HTML and CSS Syntax (Toggle Plain Text)
<div style="position:absolute;right:0px;top:0px;width:80px;height:80px;">anything</div>
I will repeat what I said in my last post though. Regarding this "separability" from a surrounding document; in a given a situation this can be useful, or it can be the absolute worst thing to use, and I find that it's rarely a case of 'somehere in-between'. If you want to put two blocks of text next to each other (horizontally), and have them maintain a justified distance to each other regardless of the width of the document; you will probably find a single row table will work better than anything using DIVs.
A DIV is really not much more than an empty block; they have no 'special' properties. With a few exceptions, you can apply any block CSS to any block element, and any text CSS to any block or inline element.
There is, I suppose, one special property for DIVs; the overflow attribute. This doesn't always do what you want it to, but in general, (and providing the DIV is absolutely sized), you can use overflow:hidden, scroll, or auto to respectively; cover up text that would exceed the DIVs absolute size; put scrollbars on the DIV at all times; or put scrollbars on the DIV if the DIV contains text that would otherwise exceed the DIVs absolute size.
Learning and using HTML and CSS appropriately is more important, and will be ultimately more profitable, than learning to design using only DIVs.
Plato forgot the nullahedron..
•
•
•
•
Learning and using HTML and CSS appropriately is more important, and will be ultimately more profitable, than learning to design using only DIVs.
That is a great post and has some excellent info in it.
![]() |
Similar Threads
- How to have the div layer center on any browser? (JavaScript / DHTML / AJAX)
- Auto Scrolling DIV tags (Site Layout and Usability)
- Heading tags and div tags (HTML and CSS)
Other Threads in the HTML and CSS Forum
- Previous Thread: Random Spacing?
- Next Thread: Simple CLI/GUI application for XHTML templates.
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form google griefers hackers hitcounter hover html ie7 ie8 iframe image images internet intranet iphone javascript jpeg layout macbook maps mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning scroll seo shopping swf swf. textcolor timecolor titletags url urlseparatedwords visualization web webdevelopment webform website windows7






