How do you make a good form? With the current (HTML 4) tools available to you, you make a simple form with a lot of text input fields, do some JavaScript validation, and make it pretty with CSS 2. With the upcoming HTML 5 features, you make a simple form with different types of input fields, make use of the browser for validation (possibly in addition to JavaScript), and make it pretty with CSS 3.
Making a form is easy!
"Wait a minute," you say. "There's got to be more to it than that. I heard that if you put your form interspersed in a paragraph, for example, the percentage of people who fill it out goes up dramatically. There's got to be more to it than input fields, JavaScript, and CSS. Where's the magic?"
I'm glad you asked.
- Make it appealing without sacrificing usability. Set off the form from the surrounding elements through the strategic use of pictures, borders around the form, or a different background color. Also, use enough whitespace (but don't float your label on the left edge of the screen and your text field on the right – that's too much whitespace).
- Take advantage of the HTML5 form validation as soon as it's widely implemented. The less you have to rely on server-side validation, the less load you'll put on the servers and the happier your customers will be.
- Speaking of HTML5, start using the new form input types and placeholder text now. They degrade gracefully to regular text input fields in older browsers, and they provide advanced functionality to people using modern desktop browsers and Mobile Safari.
- Only collect the information you absolutely have to. Why ask about a user's favorite color in a form to sign up for a mailing list? (Okay, that's an extreme example, but you get the point.)