Jump to content

Anti-tables


smerny

Recommended Posts

What is the reason that everyone seems against using tables in their HTML? Even with forms?like this example i just saw:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>  <head>	<title>Register</title>	<style type="text/css">	.error_text {	  color: #FF0000;	  width: 400px;	  text-align: center;	}	.left_box {	  float: left;	  width: 150px;	  text-align: right;	  padding-right: 5px;	}	.right_box {	  clear: right;	}	</style>  </head>  <body>	<form action="register.php" method="post">	<input type="hidden" name="page_mode" value="register">	<div class="left_box">Email address</div>	<div class="right_box"><input type="text" name="email" size="30" maxlength="255"></div>	<div class="left_box">Name</div>	<div class="right_box"><input type="text" name="name" size="30" maxlength="255"></div>	<div class="left_box">Password</div>	<div class="right_box"><input type="password" name="password" size="30"></div>	<div class="left_box">Confirm Password</div>	<div class="right_box"><input type="password" name="conf_password" size="30"></div>	<div class="left_box"> </div>	<div class="right_box"><input type="submit" value="Register" size="30"></div>	</form>  </body></html>

I'm still fairly new to coding and I just want to make sure that I develop the right habits and know why they are right..

Link to comment
Share on other sites

1. Tables limit design possibilities. In a table, everything needs to be based on columns and rows. A design based on CSS can be more flexible. You have more positioning opportunities.2. Tables usually require more HTML. You need the <table> tags, the <tr> tags, and the <td> tags. But only the <td> holds content. So it's wasteful. Sophisticated designs require tables inside of tables, making the mark-up especially wasteful, and hard to read.3. Table-based layout is unsemantic. The current trend is to put content inside tags that literally identify what kind of content is inside. That is what is meant by semantic mark-up. The tags match the meaning.So, for example, if you have a <h1> tag, it should be at the top of your document and should identify the theme of the entire page. And there should only be one <h1> tag. If you use <h1> as a shortcut to having big, bold text, then you are not using the tag semantically.The same idea works with tables. A table should hold content that is tabular -- that is, content that could appear in a spreadsheet.---That said, we all recognize that a table is sometimes the quickest, simplest way to layout a basic page, especially if you use a WYSIWYG editor. When someone (on this board, anyway) says you should not use tables for layout, we are assuming that you care about crafting the best possible page that you can. We don't use the word "craft" around here very much, but I think it names the assumption that many of us are working under.

Link to comment
Share on other sites

I think the simple explanation is that its nearly always better to separate Markup (HTML) Design (CSS) and Functionality (JavaScript)it makes the code easier to read and maintain, like Deirdre's Dad wrote. it can very quickly become very cluttered with all the tables inside each other./mads

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...