Form Markup, Usability, and Accessibility

Before you style a form, you need to know how to mark it up properly in a way that will not only maximize your styling options with CSS, but keep it usable and accessible for your users.

Laying out Forms with CSS

The following links give examples and/or instructions on how to lay out forms without tables. They don't necessarily cover how to style the form elements themselves (see the next section on this page for those links).

Styling Form Elements

There is a limited amount of styling that you can do to form elements, and this varies by browser. This is because form elements are still controlled by the OS to some degree. In some browsers, this tie is greater than others. Many argue that it is good that forms can't be styled too radically because it would hurt usability to do so -- users rely on an input element looking like an input element so they know what action to take.

Adding height to input and select elements

A few notes regarding styling input and select elements with height.

In my brief testing, only Opera seems to deal with flexible height settings on these elements.

For instance, I have styled my input and select items with {height: 2em;} with the following results:

Note that not adding height to these elements produces the same results as above.

Scalable text sizes for input fields and buttons

If your goal is having form fields that get larger (or smaller) when the user changes the browser text size, try this:

input {
  font-size:0.8em; /* whatever default font size you want */
}

This should give you scalable form elements when changing the browser text size in IE, Firefox, etc. Apparently, form elements and their text do not scale in those browsers unless a font-size attribute is added.

Form Styling Bugs