Skip to content

Technique C17:Scaling form elements which contain text

Applicability

(X)HTML, CSS

This technique relates to 1.4.4: Resize Text (Advisory).

Description

The objective of this technique is to ensure text-based form controls resize when text size is changed in the user agent. This will allow users to enter text and read what they have entered in input boxes because the text is displayed at the size required by the user.

Text-based form controls include input boxes (text and textarea) as well as buttons.

Examples

Example 1: A Contact Form

A Contact Us form has some introductory information and then form controls for users to enter their first name, last name, telephone number and email address. All of the text and form controls have been implemented in a scalable way. This includes specifying a font size for the form controls themselves because the font size is not inherited in Internet Explorer.

The XHTML component:

<h1>Contact Us</h1>
<p>Please provide us with your details and we will contact you as soon as we can. Note that all of the form fields are required.</p>
<label for="fname">First Name</label><input type="text" name="fname" id="fname" /><br />
<label for="lname">Last Name</label><input type="text" name="lname" id="lname" /><br />
<label for="phone">Telephone</label><input type="text" name="phone" id="phone" /><br />
<label for="email">Email</label><input type="text" name="email" id="email" /><br />
<input type="submit" name="Submit" value="Submit" id="Submit" />

The CSS component:

h1 { font-size: 2em; }
            p, label, input { font-size: 1em; }

Working example of this code: Example of resizing input with CSS.

Example 2: Radio button

This example works in IE with its text size feature. However, it doesn't scale in Firefox 2.0.

The XHTML component:

<input type="radio" name="r1" value="r1" id="r1" class="geomsize" />
<input type="checkbox" name="c1" id="c1" value="c1" class="geomsize" />

The CSS component:

input.geomsize {
width: 1.2em;
height: 1.2em;}

Working example of this code: Example of resizing radio buttons and checkboxes with CSS.

Tests

Procedure

  1. Enter some text into text-based form controls that receive user entered text.
  2. Increase the text size of the content by 200%.
  3. Check that the text in text-based form controls has increased by 200%.

Expected Results

  • #3 is true.
Back to Top