Web Standards
  Home arrow Web Standards arrow Page 4 - Web Forms
IBM developerWorks
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WEB STANDARDS

Web Forms
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 41
    2004-08-23

    Table of Contents:
  • Web Forms
  • Method B: Tableless, but Cramped
  • The label E
  • Defining Style
  • tabindex Attribute
  • Styling Forms
  • Using label
  • Use fieldset to Group Form Sections
  • Three-dimensional legend

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Web Forms - Defining Style


    (Page 4 of 9 )

    The simplest style we could add would be to easily remove the default indenting of <dd> elements within our form:

    form dd {
    margin: 0;
    }

    The preceding snippet of CSS would render our Method D example as viewed in Figure 5-7.

     cederholm

    Figure 5-7. Definition list form example with <dd> margins removed

    The table-like format of Method A could also be achieved by floating <dt> elements within our form:

    form dd {
    margin: 0;
    }

    form dt {
    float: left;
    padding-right: 10px;
    }

    By floating the <dt> elements to the left, the form controls contained in <dd> tags will align themselves to the right, as seen in Figure 5-8. You’ll notice that the form controls don’t line up with each other perfectly—but at the very least this illustrates that while it’s possible to use a <dl> tag to lay out a form, the layout doesn’t have to put each element on its own line.

    In fact, because of the presence of the <dl>, <dt>, and <dd> elements—which are in addition to the form <label>  

    cederholm 

    Figure 5-8. Form layout with floated elements

    Summary

    We’ve looked at four different ways to mark up the same simple form, noting the pros and cons of each. It’s important to point out that the accessibility features that we added to Methods C and D could, of course, be easily added to the first two methods as well—and those methods would be better because of those added features.

    Neither one of the methods that we’ve looked at here are necessarily miles ahead of the others in terms of a “best solution.” But it’s valuable to know your options—and what you can combine from all four to create better forms in your own projects.

    Let’s recap the differences between the methods presented.

    Method A:

    • Visually, it’s a nice, neat way to organize form controls and labels—especially for larger complex forms.
    • However, using a table for such a simple form seems a bit unnecessary.

    Method B:

    • Simple markup will degrade nicely in text browsers and small-screened devices.
    • Visually, just using <br /> tags results in a cramped layout.

    Method C:

    • Simple markup will degrade nicely in text browsers and small-screened devices.
    • Allows for labels and controls of different lengths without any “lining up” issues.
    • Contains an important accessibility feature (that could also be applied to the previous methods).

    WEB STANDARDS ARTICLES

    - Completing a Configuration for Chrome and a ...
    - Getting Connected with Firefox and Chrome
    - Configuring Servers and Databases with Chrome
    - Configuring Firefox for Chrome and a Server
    - Designing the Elements of a Web Page
    - Matching div heights with CSS and JavaScript
    - Forms
    - Get Down With Markup
    - If I Said You Had a Beautiful Body...
    - Web Standards in Dreamweaver Part 3
    - Web Standards in Dreamweaver, Part 2
    - Web Forms
    - Making Lists Using XHTML
    - Web Standards in Dreamweaver, Part 1







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway