Forms and Web standards

Reply

Join Date: Sep 2006
Posts: 162
Reputation: Cerberus is an unknown quantity at this point 
Solved Threads: 14
Cerberus Cerberus is offline Offline
Junior Poster

Forms and Web standards

 
0
  #1
Sep 30th, 2007
Hi. I was wondering if there was a 'best practice' for formatting an html form. I assume that you are not supposed to use tables for this.

Any ideas?

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 21
Reputation: Shaffer is an unknown quantity at this point 
Solved Threads: 2
Shaffer Shaffer is offline Offline
Newbie Poster

Re: Forms and Web standards

 
0
  #2
Sep 30th, 2007
Hello,
I am sorry, but I really don't know what you mean...
Can you please be more specific?


Shaffer.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 427
Reputation: autocrat is on a distinguished road 
Solved Threads: 12
autocrat autocrat is offline Offline
Posting Pro in Training

Re: Forms and Web standards

 
1
  #3
Sep 30th, 2007
Well...

Use the <fieldset> tag to collect related parts of the form together (if a large form).

Apply <legend> to help indicate what the form pertains to.

Ensure all Inputs have a <label> tag.
Also ensure all Labels/Inputs have unique IDs.

The label should go first for most inputs, (text, text area etc.), and last for things like Checkbox lists, radio groups etc.

Use the font-size tag for the Label/Inputs, using % or EM units.

Apply styling for :focus for inputs so that users can see which form element that are currently in (such as changing the BG colour or altering the Border Colour etc.).
(NOTE: doesn't work on IE6.)

Consider applying a little JS to enhance usability (autofocus the first part of a form and enable IE6 to use the :focus).


-------


If it helps....


HTML and CSS Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head>
  2. <title>Center Block Element 2</title>
  3. <style type="text/css">
  4.  
  5. html
  6. {
  7. margin: 0;
  8. padding: 0;
  9. font-size: 100%;
  10. font-family: trebuchet, arial, sans-serif;
  11. }
  12.  
  13. body
  14. {
  15. margin: 0;
  16. padding: 10px;
  17. font-size: 62.5%;
  18. }
  19.  
  20. form
  21. {
  22. margin: 0;
  23. padding: 0;
  24. width: 500px;
  25. }
  26.  
  27. fieldset
  28. {
  29. margin: 0;
  30. padding: 10px;
  31. border: 1px solid #d6d6d6;
  32. display: block;
  33. }
  34.  
  35. legend
  36. {
  37. margin: 0 0 15px 0;
  38. padding: 4px 8px;
  39. border: 0px solid #d6d6d6;
  40. font-weight: bold;
  41. font-size: 1.6em;
  42. background-color: #000000;
  43. color: #ffffff;
  44. }
  45.  
  46.  
  47. .formelementwrappersingle
  48. {
  49. margin: 2px;
  50. padding: 0;
  51. float: left;
  52. clear: both;
  53. width: 40em;
  54. border: 1px solid #c2c2c2;
  55. background-color: #f6f6f6;
  56. }
  57.  
  58. .formelementwrapperdoubleinline
  59. {
  60. margin: 2px;
  61. padding: 0;
  62. float:left;
  63. width: 19em;
  64. border: 1px solid #c2c2c2;
  65. background-color: #f6f6f6;
  66. }
  67. .formelementwrapperdoublebreak
  68. {
  69. margin: 2px;
  70. padding: 0;
  71. float:left;
  72. clear: both;
  73. width: 19em;
  74. border: 1px solid #c2c2c2;
  75. background-color: #f6f6f6;
  76. }
  77.  
  78. label
  79. {
  80. margin: 0;
  81. padding: 3px;
  82. font-weight: bold;
  83. display: block;
  84. width: 15em;
  85. float: left;
  86. font-size: 1.2em;
  87.  
  88. }
  89.  
  90. input.textinput, textarea.textarea
  91. {
  92. background-color: #ffff99;
  93. font-size: 1.4em;
  94. border: 1px solid #c2c2c2;
  95. }
  96.  
  97. input.textinput:focus, textarea.textarea:focus
  98. {
  99. background-color: #ffffff;
  100. font-size: 1.4em;
  101. border: 1px solid #d6d6d6;
  102. }
  103.  
  104.  
  105. </style>
  106.  
  107. </head>
  108.  
  109.  
  110. <body>
  111.  
  112.  
  113. <form>
  114.  
  115. <fieldset>
  116. <legend>Test Form 1</legend>
  117.  
  118. <div class="formelementwrappersingle">
  119. <label for="name">
  120. Name
  121. </label>
  122. <input id="name" name="name" type="text" class="textinput" />
  123. </div>
  124.  
  125.  
  126. <div class="formelementwrappersingle">
  127. <label for="description">
  128. Description
  129. </label>
  130. <textarea id="description" name="description" class="textarea"></textarea>
  131. </div>
  132.  
  133. </fieldset>
  134.  
  135.  
  136.  
  137.  
  138. <fieldset>
  139. <legend>Test Form 2</legend>
  140.  
  141. <div class="formelementwrapperdoubleinline">
  142. <label for="colourchoice_0">
  143. <input type="radio" name="colourchoice" id="colourchoice_0" title="Red" class="radioinput" checked="checked" />
  144. Red
  145. </label>
  146. </div>
  147. <div class="formelementwrapperdoubleinline">
  148. <label for="colourchoice_1">
  149. <input type="radio" name="colourchoice" id="colourchoice_1" title="Blue" class="radioinput" />
  150. Blue
  151. </label>
  152. </div>
  153.  
  154. </fieldset>
  155.  
  156.  
  157.  
  158.  
  159. <fieldset>
  160. <legend>Test Form 3</legend>
  161.  
  162. <div class="formelementwrapperdoublebreak">
  163. <label for="animalchoice_0">
  164. <input type="radio" name="animalchoice" id="animalchoice_0" title="Cat" class="radioinput" checked="checked" />
  165. Cat
  166. </label>
  167. </div>
  168. <div class="formelementwrapperdoublebreak">
  169. <label for="animalchoice_1">
  170. <input type="radio" name="animalchoice" id="animalchoice_1" title="Dog" class="radioinput" />
  171. Blue
  172. </label>
  173. </div>
  174.  
  175. </fieldset>
  176.  
  177. </form>
  178. </body>
  179. </html>
Last edited by autocrat; Sep 30th, 2007 at 12:33 pm. Reason: Code
Sometimes life holds wonderful suprises - shame I sleep through them all.
http://www.choose-easyweb.com - Not my design, nor my idea :)
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 162
Reputation: Cerberus is an unknown quantity at this point 
Solved Threads: 14
Cerberus Cerberus is offline Offline
Junior Poster

Re: Forms and Web standards

 
0
  #4
Sep 30th, 2007
That's a really good example. Thank you.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 427
Reputation: autocrat is on a distinguished road 
Solved Threads: 12
autocrat autocrat is offline Offline
Posting Pro in Training

Re: Forms and Web standards

 
0
  #5
Sep 30th, 2007
Not a problem - let me know if you want any extra help with it (Forms can be a sod sometimes (esp. if you don't do them that often!)
Sometimes life holds wonderful suprises - shame I sleep through them all.
http://www.choose-easyweb.com - Not my design, nor my idea :)
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 164
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: Forms and Web standards

 
0
  #6
Oct 7th, 2007
Tables are not deprecated. They are just discouraged for use to format pages for purposes other than tables.

If the form is like an invoice form (with several blanks on each line), there is no reason why you shouldn't use a table to contain it.

Also, the alternate methods the W3C prefers don't always work, don't work inside some other tags, and fall apart if the browser window is reduced in size. So, if you can't get it to work, don't waste hours on it; just use a table instead.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC