 |
| HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 13th, 2004, 11:09 AM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
very simple HTML question
Hi,
I just want to know which way is technically correct to put tables one after another (not side by side), or both ways are correct, bcz both produce the same results.
<body>
<table border="1" width="100%" cellspacing="0" cellpadding="0">
<tr><td>Yes</td></tr>
</table>
<table border="1" width="100%" cellspacing="0" cellpadding="0">
<tr><td>NO</td></tr>
</table>
</body>
***********************************************
<body>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr><td>
<table border="1"
width="100%"cellspacing="0"cellpadding="0">
<tr><td>Yes</td></tr>
</table>
</td></tr>
<tr><td>
<table border="1" width="100%" cellspacing="0"
cellpadding="0">
<tr><td>NO</td></tr>
</table>
</td></tr>
</table>
</body>
|
|

July 13th, 2004, 11:18 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
There is no technically correct way. However, I would go with the side-by-side method, as it uses less code.
Now, if you want to be "technically correct", here are some unrequested observations of mine....
The border, cellspacing and cellpadding attributes are depreciated and should be replaced with CSS equivalents, such as border, border-collapse, margin and padding.
Tables are generally dead, so far as using them for site layout goes. Use floating content boxes instead. Tables should be used for displaying organized data, such as a grid displaying rows from a database.
And, how can you be sure they produce the same results on all versions of all browsers on all operating systems? This is why CSS is a good alternative to depreciated tags and attributes.
Anyway, just my $.02.
HTH,
Snib
<><
|
|

July 13th, 2004, 11:47 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 425
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Snib, that isn't totally true. Cellspacing and cellpadding are not deprecated. See:
http://www.w3.org/TR/html401/index/attributes.html
'margin' doesn't apply to table cells.
http://www.w3.org/TR/REC-CSS2/tables.html#q7
The table, as a whole, can have a margin but that's no substitute for the html attributes mentioned.
I don't understand the question since the two examples create two different layouts. Nested tables are better avoided if possible though. There are other ways to get two tables side by side (float). And as Snib said, why tables? Are they for data? If so why two one cell tables?
(o<
//\ =^..^=
|
|

July 13th, 2004, 11:48 AM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks for your reply. Waht is "floating content boxes" ? do you mean <div> statements ?
|
|

July 13th, 2004, 06:54 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
cellspacing and cellpadding aren't deprecated but they should be replaced with CSS equivalents when possible.
Those are the border-spacing and border-collapse properties for cellspacing and simply the padding property for cellpadding.
I think IE doesn't yet support border-spacing, but it does support border-collapse. So to get cellspacing="0" in IE you'd use border-collapse: collapse; instead. Other browsers support the border-collapse property as well. As far as border-spacing that is supported by other browsers but not by IE. So if you need spacing between cells in IE, the cellspacing attribute is still required, otherwise the whole thing can be handled using CSS.
http://www.w3.org/TR/CSS21/tables.html
Regards,
Rich
::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
|
|

July 13th, 2004, 07:05 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Are those attributes depreciated in XHTML? I can't find the XHTML equivalent of the link you posted....
Snib
<><
|
|

July 13th, 2004, 07:10 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
nusrati,
By floating content boxes, I mean <div>s that have the CSS property float:
<div style="float:left">i'm on the left</div>
<div style="float:right">i'm on the right</div>
HTH,
Snib
<><
|
|

July 13th, 2004, 07:22 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 425
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
There aren't any. Deprecation took place in HTML 4.0. Uhm...1998. That's why this doesn't need more than one page:
http://www.w3.org/TR/2001/WD-xhtml1-20011004/
"XHTML 1.0, a reformulation of HTML 4 as an XML 1.0 application".
Deprecated stuff is duly noted in the XHTML 1.0 Transitional doctype definition though.
http://www.w3.org/TR/2001/WD-xhtml1-...ansitional.dtd
For lighter reading the HTML 4.01 spec still goes.
Nothing new under the sun. What's new is the interest for Standards and the bandwagon it all has turned into.
(o<
//\ =^..^=
|
|

July 13th, 2004, 07:24 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
Quote:
quote:Originally posted by Snib
nusrati,
By floating content boxes, I mean <div>s that have the CSS property float:
<div style="float:left">i'm on the left</div>
<div style="float:right">i'm on the right</div>
|
That's not likely to produce the desired effect. This is closer to the table layout that he presented.
Code:
<!DOCTYPE html PUBLIC "-/pp/W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> Floating div </title>
</head>
<body style="margin: 0;">
<div style="float: left;
border: 1px solid black;
width: 50%">
Yes
</div>
<div style="margin-left: 50%;
border: 1px solid black;">
No
</div>
</body>
</html>
Regards,
Rich
::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
|
|

July 13th, 2004, 07:29 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
Oops, nevermind, you weren't trying to float at all!
This is the equivalent:
Code:
<div style='border: 1px solid black;'>
Yes
</div>
<div style='border: 1px solid black;'>
No
</div>
As you can see this is considerably less markup and more desirable than tables for that reason.
Regards,
Rich
::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
|
|
 |