Trademark Web Designs

Submit Article

If you would like to submit an article, click the button below.

Categories

<-- Back to Current Category

Stylish and Accessible Forms using CSS

By: Sam Hickson, Thu Sep 20th, 2007

Stylish and accessible forms in CSS

The majority of sites designed these days have at least one form. If you're a web designer then you'll know that creating a template is essential if you are to be efficient in your work.

Many times I've compromised on a form's design due to time restrictions. Below is a template that I use and that is quite flexible in its design. This form allows for any type of input field from a simple text field to a group of radio buttons. If your quite comfortable with CSS then please feel free to adapt this code.

The fun you can have with this form can really change the way your forms look and make a great deal of difference to your overall web site design.

XHTML CODE

The link below shows a basic form structure. I've used ordered lists (ol) to segment the form and (li) tags for each row of the form just as I find this easily breaks up the code for use by novice CSS users.

XHTML Code and example

Additional Tags

If you look through the code you will see some tags which you may deem as unnecessary (i.e
tags after the radio button). These are to enable a cross browser compatible layout. Within the CSS code you will notice at the beginning that all the margins and padding are set to zero. Alternatively you could place the form in a div with zero margins and padding but it is entirely up to you.

CSS Code

CSS Code and example

Browser Compatibility

Currently this form has been tested and works in IE5.5, IE6.0 and IE7 and Firefox.

About the Author

Sam Hickson founded a Hatch Media http://www.hatchmedia.co.uk in 2006. Since this time i've written many articles that can be viewed across the internet. Most articles are related to CSS but others relate to XHTML, SEO and many more.