3 Replies - 442 Views - Last Post: 27 July 2014 - 02:18 PM

#1 kevin_mchugh  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 70
  • Joined: 08-April 09

DIV's and Tables. Why use one and not the other?

Posted 26 July 2014 - 02:59 AM

Hello All,

So this has bugged me for a REALLY long time. Basically I know that you NEVER use tables for layout work. I know you ALWAYS use div's (Or HTML5 elements!) but I still don't know why? I mean beyond the "Just because" or "It's the standard" is their an actual reason?

I know that it would be a NIGHTMARE doing large scale areas or complete websites with tables......but....

The reason I am asking now is that I am working on a webcomic and it would just be simpler to do:

<table>

	<tr>
		<td colspan="4">Page #1</td>
	</tr>
	<tr>
		<td colspan="4"><img src="1.jpg" alt="pic1" /></td>
	</tr>
	<tr>
		<td><a href="#">First</a></td><td><a href="#">Previous</a></td><td><a href="#">Next</a></td><td><a href="#">Last</a></td>
	</tr>

</table>



For displaying the actual comic pages than to do:

<div id="wrapper">

	<div id="title">
		<p>Page #1</p>
	</div>

	<div id="comicImage">
		<img src="1.jpg" alt="pic1" />
	</div>
	
	<div id="navigation">
		<ul>
			<li><a href="#">First</a></li>
			<li><a href="#">Previous</a></li>
			<li><a href="#">Next</a></li>
			<li><a href="#">Last</a></li>
		</ul>
	</div>
	
</div>



And then spend forever floating, aligning, css(ing?) the elements.

I know I am not going to get arrested by the standards police or have my website taken off line because of it....but there must be reason...surely....

Sorry if this seems like a ridiculous question but you will never learn unless you ask.

Apologies as always to anyone I may have upset by posting this in the wrong place.

Regards

Kevin

Is This A Good Question/Topic? 0
  • +

Replies To: DIV's and Tables. Why use one and not the other?

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3467
  • View blog
  • Posts: 11,768
  • Joined: 12-December 12

Re: DIV's and Tables. Why use one and not the other?

Posted 26 July 2014 - 03:23 AM

There are lots of discussions on this topic:

http://stackoverflow...-layout-in-html

http://blog.silktide...or-layout-ever/

and debate and misunderstanding.

Tables are intended to display tabular data, not to layout a page - into blocks and sections. Modern css can do this very effectively.

People then mistakenly get hold of the notion to "never use tables", which is incorrect. Look at a section of a page you are building: is it an ordered (regular) grid of rows and columns? Then it should be a table.

It is not a crime to use a table to layout a page (nested tables are a crime!), but it is extremely rare for an entire page to be an ordered set of rows and columns.

Your code example isn't a table. (With experience you can even look at page and see the gridlines behind what should be a table ;)/> )

This post has been edited by Dormilich: 26 July 2014 - 07:09 AM
Reason for edit:: orthography

Was This Post Helpful? 1
  • +
  • -

#3 kevin_mchugh  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 70
  • Joined: 08-April 09

Re: DIV's and Tables. Why use one and not the other?

Posted 27 July 2014 - 02:11 PM

Thanks for the links.

I bit the bullet and re-wrote the whole thing in DIV's

I hate IE but that's another matter.
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3467
  • View blog
  • Posts: 11,768
  • Joined: 12-December 12

Re: DIV's and Tables. Why use one and not the other?

Posted 27 July 2014 - 02:18 PM

IE? Me too.

Don't go too far in the opposite direction and catch divitis.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1