Form elements

Keep forms as simple as possible, see form example for more information.

Rules for form elements

Options available


Fieldsets and legends

Use fieldsets to group related form controls. The first element inside a fieldset must be a legend element that describes the group.

Example

Personal details

Enter your postcode without any spaces. For example, KY169AL.
Code

Personal details

Enter your postcode without any spaces. For example, KY169AL.

Input fields

Input types

Example
Example text input type.
Example email input type.
Example telephone input type.
Example numeric input type.
Example password input type.
Code
Example text input type.
Example email input type.
Example telephone input type.
Example numeric input type.
Example password input type.

Labels

Example
Code

Optional fields

If you do ask for optional information, you must mark the labels of optional fields with (optional).

Example
Code

Hint text

Example
Enter your postcode without any spaces. For example, KY16 9AL.
Code
Enter your postcode without any spaces. For example, KY16 9AL.

Submit buttons

Example
Code

Textarea

Allows for multiple lines of text.

Example
Code

Textarea with input limit counter

Example
Code

Checkboxes inline

Example
What colours do you like?

Select all options that apply.

Code
What colours do you like?

Select all options that apply.


Checkboxes stacked

Example
What colours do you like?

Select all options that apply.

Code
What colours do you like?

Select all options that apply.


Checkboxes inline (small)

Smaller checkboxes can be used when these elements need to be less visually prominent.

Example
What colours do you like?

Select all options that apply.

Code
What colours do you like?

Select all options that apply.


Checkboxes stacked (small)

Smaller checkboxes can be used when these elements need to be less visually prominent.

Example
What colours do you like?

Select all options that apply.

Code
What colours do you like?

Select all options that apply.


Radio buttons inline

These let users choose a single option from a list.

Example
How many fudge doughnuts would you like?

Remember that eating too many doughnuts may be bad for you.

Code
How many fudge doughnuts would you like?

Remember that eating too many doughnuts may be bad for you.


Radio buttons stacked

These let users choose a single option from a list.

Example
How many fudge doughnuts would you like?

Remember that eating too many doughnuts may be bad for you.

Code
How many fudge doughnuts would you like?

Remember that eating too many doughnuts may be bad for you.


Radio buttons stacked with conditional

You may reveal an additional input field, depending on the radio button selected.

Example
How many fudge doughnuts would you like?

Remember that eating too many doughnuts may be bad for you.

Code
How many fudge doughnuts would you like?

Remember that eating too many doughnuts may be bad for you.


Select box

Example

Please select your student status.

Code

Please select your student status.


Select box with conditional

You may reveal an additional input field, depending on the option selected.

Example

Please select your student status.

Code

Please select your student status.


Date picker

Use date picker for inputting date elements.

Example
Code

File upload

This element uses the native input: type='file'. This is so the element gains focus when tabbing through the page. It also ensures the element functions when:

Example
Code

Input addons

Addons may be used when the input field is always going to be prefixed with a particular value, for example collecting only the username for an @st-andrews.ac.uk email address.

Example
£
.00
Enter only the username part of your email address. For example, kt123.
@st-andrews.ac.uk
Code
£
.00
Enter only the username part of your email address. For example, kt123.
@st-andrews.ac.uk