<table border=0> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> </table>
<div> instead of <table>
Started by archive02, Sep 03 2007 07:13 AM
11 replies to this topic
#1
Posted 03 September 2007 - 07:13 AM
I've been suggested to use div tags instead of table tags to align objects on my webpage. As I understand div tags are only for setting styles though so how is it possible for me to align objects with div tags? For example, how could I create three columns and 2 rows with divs?
|
|
|
#2
Posted 04 September 2007 - 04:40 AM
archive02 said:
I've been suggested to use div tags instead of table tags to align objects on my webpage. As I understand div tags are only for setting styles though so how is it possible for me to align objects with div tags? For example, how could I create three columns and 2 rows with divs?
Okay, first of let me say that in my opinion it is not technically wrong to use tables in your layout. However, the technology has increased to a point where CSS does a better job. The code is cleaner, and separated from the actual html source code. It increases readability and actually makes updating and maintaining a site or page much easier. Plus tables take longer to render.
This site is a perfect example... Knoxville Life Church if you have firefox, disable the css when you get to this page, you will see that it is all div tags...
Morale of the story is learn CSS
Check out this section of the forum, it will answer your question: Div for positioning - HTML Help Central
Everything in Life can be solved with an 'If/Else' statement.
Life is like one big try/catch statement, nested within a loop.
-Will
[SIGPIC][/SIGPIC]
Life is like one big try/catch statement, nested within a loop.
-Will
[SIGPIC][/SIGPIC]
#3
Posted 04 September 2007 - 04:59 AM
My definition of the two tags:
div - For layout.
table - For showing different data.
The table tag has never been meant to be used for designing layout, or similar. It's meant to be used for showing data in an easy an effective way, while you should use the div tag, when you need to design layouts.
This is a heavily debated topic, so I'd like to hear other responses too. Maybe I am wrong?
div - For layout.
table - For showing different data.
The table tag has never been meant to be used for designing layout, or similar. It's meant to be used for showing data in an easy an effective way, while you should use the div tag, when you need to design layouts.
This is a heavily debated topic, so I'd like to hear other responses too. Maybe I am wrong?
#4
Posted 04 September 2007 - 05:12 AM
I would hope not. For the 7 years I've been a developer I've been told of the horrors of table-based layouts. I would like to believe that it is deprecated, CSS gives us that edge back. Or that one word: Flexibility.
Everything in Life can be solved with an 'If/Else' statement.
Life is like one big try/catch statement, nested within a loop.
-Will
[SIGPIC][/SIGPIC]
Life is like one big try/catch statement, nested within a loop.
-Will
[SIGPIC][/SIGPIC]
#5
Posted 04 September 2007 - 06:12 AM
I don't think the table tag is deprecated yet. It's a fine solution for the purpose I mentioned in my last post; for showing different kinds of data. But I'll never use it for layout or anything else than showing data.
I don't think you can mix CSS into this discussion. CSS can be used on both table- and div tags. But you're right: CSS is way better, than putting the style right onto the tags (using the style attribute)
I can't say I like the table tag over the div tags, because their purposes are different. But let's say it in this way: in 99% of my time developing websites, I'm using div tags over table tags. And I'm using CSS always, of course.
I don't think you can mix CSS into this discussion. CSS can be used on both table- and div tags. But you're right: CSS is way better, than putting the style right onto the tags (using the style attribute)
I can't say I like the table tag over the div tags, because their purposes are different. But let's say it in this way: in 99% of my time developing websites, I'm using div tags over table tags. And I'm using CSS always, of course.
#6
Posted 05 September 2007 - 06:08 AM
Can either of you show me an example using <div>s with the table structure I posted above?
#7
Posted 06 September 2007 - 05:33 AM
@void
I agree with you on that. 99% of the time, it seems as if most people stay away from table driven websites.
However, I am not indifferent to the idea. I have seen successfully written table-based layouts using CSS, as well as had to use them myself.
I'm not saying its down right wrong. I just think there are better ways to code. Obviously the <table> tag has it's uses.
I just am completely against using tables as a layout. Its such a horrible structure for your code.
@archive02
Check this section out. It will answer your question....
Div for positioning - HTML Help Central
I agree with you on that. 99% of the time, it seems as if most people stay away from table driven websites.
However, I am not indifferent to the idea. I have seen successfully written table-based layouts using CSS, as well as had to use them myself.
I'm not saying its down right wrong. I just think there are better ways to code. Obviously the <table> tag has it's uses.
I just am completely against using tables as a layout. Its such a horrible structure for your code.
@archive02
Check this section out. It will answer your question....
Div for positioning - HTML Help Central
Everything in Life can be solved with an 'If/Else' statement.
Life is like one big try/catch statement, nested within a loop.
-Will
[SIGPIC][/SIGPIC]
Life is like one big try/catch statement, nested within a loop.
-Will
[SIGPIC][/SIGPIC]
#8
Posted 06 September 2007 - 07:15 AM
I'm following your "philosophy" too. I don't think that table-layouts are worser than if you had been using divs for the work, but in my opinion it's more "right" to use table and div in the "right" way. Data showing with tables, and layouts and other stuff with divs.
I had a similar discussion on a danish forum, regarding the two PHP-functions, echo and print. I'm not saying that it's bad to use print in a stand-alone statement, but echo would be better. echo don't return anything, print does. What shall you do with the return-value from print? Nothing! The value is always the same (1) - so why not just use echo? I think it's better to use echo in this situation. It also lead to a post on my blog, if anyone is interested (though my english is pretty bad.)
The last paragraph was slightly off-topic and irrelevant, but I think it fits in anyway. It kinda tells what I mean, in some way(?)
I had a similar discussion on a danish forum, regarding the two PHP-functions, echo and print. I'm not saying that it's bad to use print in a stand-alone statement, but echo would be better. echo don't return anything, print does. What shall you do with the return-value from print? Nothing! The value is always the same (1) - so why not just use echo? I think it's better to use echo in this situation. It also lead to a post on my blog, if anyone is interested (though my english is pretty bad.)
The last paragraph was slightly off-topic and irrelevant, but I think it fits in anyway. It kinda tells what I mean, in some way(?)
#9
Posted 07 September 2007 - 05:10 AM
Thanks, that thread link helped a lot. Particularly the code at the bottom:
So the consensus here is to use CSS and divs rather than tables?
<div id="menu"> <ul> <li><a href="page.htm">Link</a></li> <li><a href="page.htm">Link</a></li> <li><a href="page.htm">Link</a></li> <li><a href="page.htm">Link</a></li> <li><a href="page.htm">Link</a></li> </ul> </div> <div id="content"> blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah </div>
So the consensus here is to use CSS and divs rather than tables?
#10
Guest_Jordan_*
Posted 07 September 2007 - 05:13 AM
Guest_Jordan_*
v0id said:
I had a similar discussion on a danish forum, regarding the two PHP-functions, echo and print. I'm not saying that it's bad to use print in a stand-alone statement, but echo would be better. echo don't return anything, print does. What shall you do with the return-value from print? Nothing! The value is always the same (1) - so why not just use echo? I think it's better to use echo in this situation. It also lead to a post on my blog, if anyone is interested (though my english is pretty bad.)
The last paragraph was slightly off-topic and irrelevant, but I think it fits in anyway. It kinda tells what I mean, in some way(?)
The last paragraph was slightly off-topic and irrelevant, but I think it fits in anyway. It kinda tells what I mean, in some way(?)
It is funny that you had this discussion. It was asked here once: http://forum.codecal...51-why-not.html
Although it didn't get as in depth. You should post your return value argument in that thread.
#11
Posted 08 September 2007 - 02:21 PM
v0id said:
I had a similar discussion on a danish forum, regarding the two PHP-functions, echo and print. I'm not saying that it's bad to use print in a stand-alone statement, but echo would be better. echo don't return anything, print does. What shall you do with the return-value from print? Nothing! The value is always the same (1) - so why not just use echo? I think it's better to use echo in this situation. It also lead to a post on my blog, if anyone is interested (though my english is pretty bad.)
echo and print aren't functions they are language constructs :P
Anyway echo accepts parameters which allows you to avoid concatenation - hence increasing your codes performance. Stay tuned for more info :D
#12
Posted 08 September 2007 - 09:46 PM
"Sidewinder" said:
echo and print aren't functions they are language constructs :P
Edit: I realized that; you're right. I made some fast research, and yes, I see that those aren't functions. I better do some more research before I'm posting next time. :-)


Sign In
Create Account


Back to top









