jQuery Mobile provides a complete set of finger-friendly form elements that are based on native HTML form elements.

Form structure

All forms should be wrapped in a form tag that has an action and method that will handle the form data processing on the server.

<form action="form.php" method="post"> ... </form>

Dynamic form layout

In jQuery Mobile, all form elements are designed to be a flexible width so they will comfortably fit the width of any mobile device. One optimization built into the framework is that we present labels and form elements differently based on screen width.

If a page is fairly narrow (~480px), the labels are styled as block-level elements so they will stack on top of the form element to save horizontal space.

On wider screens, the labels and form elements are styled to be on the same line in a 2-column layout to take advantage of the screen real estate.

Field containers

To improve the styling to labels and form elements on wider screens, we recommend wrapping a div or fieldset with the data-role="fieldcontain" attribute around each label/form element. The framework will add a thin vertical bottom border on this container to act as a field separator and visually align the label and form elements for quick scanning.

<div data-role="fieldcontain">
	...label/input code goes here...