Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > HTML Programming

HTML Programming Forum discussion covering HTML, XHTML, DHTML and all flavors of HTML. Hypertext Markup Language is used to create websites.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-03-2007, 11:13 AM
archive02 archive02 is offline
Newbie
 
Join Date: Nov 2006
Posts: 10
Rep Power: 0
archive02 is on a distinguished road
Default <div> instead of <table>

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?


HTML Code:
<table border=0>
     <tr>
        <td></td>
        <td></td>
        <td></td>
    </tr>
     <tr>
        <td></td>
        <td></td>
        <td></td>
    </tr>
</table>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 09-04-2007, 08:40 AM
WillB's Avatar   
WillB WillB is offline
Learning Programmer
 
Join Date: Apr 2007
Location: St. Cloud, Fl
Age: 19
Posts: 43
Rep Power: 7
WillB is on a distinguished road
Lightbulb

Quote:
Originally Posted by archive02 View Post
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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-04-2007, 08:59 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

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?
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-04-2007, 09:12 AM
WillB's Avatar   
WillB WillB is offline
Learning Programmer
 
Join Date: Apr 2007
Location: St. Cloud, Fl
Age: 19
Posts: 43
Rep Power: 7
WillB is on a distinguished road
Thumbs up

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-04-2007, 10:12 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

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.
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 09-05-2007, 10:08 AM
archive02 archive02 is offline
Newbie
 
Join Date: Nov 2006
Posts: 10
Rep Power: 0
archive02 is on a distinguished road
Default

Can either of you show me an example using <div>s with the table structure I posted above?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 09-06-2007, 09:33 AM
WillB's Avatar   
WillB WillB is offline
Learning Programmer
 
Join Date: Apr 2007
Location: St. Cloud, Fl
Age: 19
Posts: 43
Rep Power: 7
WillB is on a distinguished road
Default

@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
__________________
Everything in Life can be solved with an 'If/Else' statement.

Life is like one big try/catch statement, nested within a loop.

-Will


Last edited by WillB; 09-06-2007 at 09:34 AM. Reason: Included Link
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 09-06-2007, 11:15 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

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(?)
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 09-07-2007, 09:10 AM
archive02 archive02 is offline
Newbie
 
Join Date: Nov 2006
Posts: 10
Rep Power: 0
archive02 is on a distinguished road
Default

Thanks, that thread link helped a lot. Particularly the code at the bottom:

HTML Code:
<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?

Last edited by archive02; 09-07-2007 at 09:20 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 09-07-2007, 09:13 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,650
Last Blog:
PHP Objects, Patterns,...
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

Quote:
Originally Posted by v0id View Post
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(?)
It is funny that you had this discussion. It was asked here once: http://forum.codecall.net/php/251-why-not.html

Although it didn't get as in depth. You should post your return value argument in that thread.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -5. The time now is 06:52 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads