Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Forms an appropriate use of tables?

Reply
Thread Tools

Forms an appropriate use of tables?

 
 
Michael Wilcox
Guest
Posts: n/a
 
      09-06-2003
Is the following code a good use of tables?

<form action="store.php" method="post">
<table>
<tr><td style="text-align: right;">Name:</td><td><input type="text"
name="from"></td></tr>
<tr><td style="text-align: right;">Email:</td><td><input type="text"
name="email"></td></tr>
<tr><td style="text-align: right;">Body:</td><td><textarea
name="body"></textarea></td></tr>
</table>
<input type="submit" value="Send">
</form>

The labels (name, email, body) do refer to the adjacent cell, and it seems
like it should be acceptable, but I thought I should ask.
--
Michael Wilcox
Essential Tools for the Web Developer - http://mikewilcox.t35.com
mjwilco at yahoo dot com


 
Reply With Quote
 
 
 
 
Toby A Inkster
Guest
Posts: n/a
 
      09-06-2003
Michael Wilcox wrote:

> Is the following code a good use of tables?

(snip example)
> The labels (name, email, body) do refer to the adjacent cell, and it seems
> like it should be acceptable, but I thought I should ask.


It is pushing the bounds, but I would class it as reasonable.

Make sure to also use the <label> tag, for example:

<tr>
<td style="text-align: right;">
<label for="from">Name</label>:
</td>
<td>
<input type="text" name="from" id="from">
</td>
</tr>

This explicitly specifies the relationship between input fields and their
labels. Note that the "for" attribute specifies an *id*, not a *name*, so
it means you have to add both an *id* _and_ a *name* to your fields. This
does not cause any problems in submitting the forms.

--
Toby A Inkster BSc (Hons) ARCS | private.php?do=newpm&u= | pgp:0x6A2A7D39
aim:inka80 | icq:6622880 | yahoo:tobyink | jabber:
http://www.goddamn.co.uk/tobyink/ | "You've got spam!"
playing://(nothing)
 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      09-06-2003
"Michael Wilcox" <> wrote:

> Is the following code a good use of tables?


Opinions differ on the question whether a set of a field label, input
field pairs logically constitutes a table. If you ask me, it does.
On the practical side, for accessibility it would be useful to associate
the labels with the fields in markup, but this is also true (though not as
important) when tables are not used. Example:

<tr><td ...><label for="name" Name:</td><td><input id="name" type="text"
name="from"></td></tr>

By the way, your textarea lacks the required rows and cols attributes,
which means that the effect is unpredictable:

> <tr><td style="text-align: right;">Body:</td><td><textarea
> name="body"></textarea></td></tr>
> </table>


Better use some rows and cols attributes, even if you have a style sheet
that may override those dimensions.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


 
Reply With Quote
 
Michael Wilcox
Guest
Posts: n/a
 
      09-06-2003
Isofarro <> wrote:
> No.


Why not?

> The table cell holding the text "Name:" is actually a table header so
> mark it up as such, and add in a scope="right" . Then migrate the
> style information into a stylesheet.


Why is it a table header? It only has to do with one input.
--
Michael Wilcox
Essential Tools for the Web Developer - http://mikewilcox.t35.com
mjwilco at yahoo dot com


 
Reply With Quote
 
Isofarro
Guest
Posts: n/a
 
      09-06-2003
Michael Wilcox wrote:

> Is the following code a good use of tables?


No.

>
> <form action="store.php" method="post">
> <table>
> <tr><td style="text-align: right;">Name:</td><td><input type="text"
> name="from"></td></tr>


The table cell holding the text "Name:" is actually a table header so mark
it up as such, and add in a scope="right" . Then migrate the style
information into a stylesheet.

Then encapsulate Name: in a label element with the attribute for="from".



--
Iso.
FAQs: http://html-faq.com http://alt-html.org http://allmyfaqs.com/
Recommended Hosting: http://www.affordablehost.com/
Web Standards: http://www.webstandards.org/
 
Reply With Quote
 
Isofarro
Guest
Posts: n/a
 
      09-06-2003
Michael Wilcox wrote:

> Isofarro <> wrote:
>> No.

>
> Why not?


Because its missing some structural elements. td, label, scope, table
summary

>> The table cell holding the text "Name:" is actually a table header so
>> mark it up as such, and add in a scope="right" . Then migrate the
>> style information into a stylesheet.

>
> Why is it a table header? It only has to do with one input.


You've answered the question.


--
Iso.
FAQs: http://html-faq.com http://alt-html.org http://allmyfaqs.com/
Recommended Hosting: http://www.affordablehost.com/
Web Standards: http://www.webstandards.org/
 
Reply With Quote
 
Michael Wilcox
Guest
Posts: n/a
 
      09-06-2003
Isofarro <> wrote:
> Michael Wilcox wrote:
>
>> Isofarro <> wrote:
>>> No.

>>
>> Why not?

>
> Because its missing some structural elements. td, label, scope, table
> summary


Ok, I think I fixed it up. See the whole page code at
http://codedump.phpfreaks.com/viewcode.php?id=1374
--
Michael Wilcox
Essential Tools for the Web Developer - http://mikewilcox.t35.com
mjwilco at yahoo dot com


 
Reply With Quote
 
EightNineThree
Guest
Posts: n/a
 
      09-06-2003

"Michael Wilcox" <> wrote in message
news:Ign6b.2033$ ink.net...
> Is the following code a good use of tables?
>
> <form action="store.php" method="post">
> <table>
> <tr><td style="text-align: right;">Name:</td><td><input type="text"
> name="from"></td></tr>
> <tr><td style="text-align: right;">Email:</td><td><input type="text"
> name="email"></td></tr>
> <tr><td style="text-align: right;">Body:</td><td><textarea
> name="body"></textarea></td></tr>
> </table>
> <input type="submit" value="Send">
> </form>
>
> The labels (name, email, body) do refer to the adjacent cell, and it seems
> like it should be acceptable, but I thought I should ask.


Not really.
At least they're adjacent to each other.
However, if it is accessibility you're after, you should label those inputs,
too.

http://webaim.org/howto/forms/


--
Karl Core

Charles Sweeney says my sig is fine as it is.


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use command line option '/keyfile' or appropriate project settings instead of 'AssemblyKeyFile' SenthilVel ASP .Net 1 08-04-2006 02:50 AM
forms authentication -- expired forms cookie vs. not provided forms cookie Eric ASP .Net Security 2 01-27-2006 10:09 PM
Is this an appropriate use of PUBLIC variables? darrel ASP .Net 6 01-20-2005 09:08 PM
Requesting suggestions for appropriate use of VLANs Jamie Cisco 1 09-17-2004 08:58 PM
Re: Appropriate Use of Image Stabilization James E Kropp Digital Photography 8 08-02-2003 12:49 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57