Forms

Simple CSS for HTML forms.

Default Form

To create a default inline form, add the pure-form classname to any <form> element.

A compact inline form
<form class="pure-form">
    <fieldset>
        <legend>A compact inline form</legend>
        <input type="email" placeholder="Email" />
        <input type="password" placeholder="Password" />
        <label for="default-remember">
            <input type="checkbox" id="default-remember" /> Remember me
        </label>
        <button type="submit" class="pure-button pure-button-primary">Sign in</button>
    </fieldset>
</form>

Stacked Form

To create a stacked form with input elements below the labels, add the pure-form-stacked classname to a <form> element alongside pure-form.

A Stacked Form This is a required field.
<form class="pure-form pure-form-stacked">
    <fieldset>
        <legend>A Stacked Form</legend>
        <label for="stacked-email">Email</label>
        <input type="email" id="stacked-email" placeholder="Email" />
        <span class="pure-form-message">This is a required field.</span>
        <label for="stacked-password">Password</label>
        <input type="password" id="stacked-password" placeholder="Password" />
        <label for="stacked-state">State</label>
        <select id="stacked-state">
            <option>AL</option>
            <option>CA</option>
            <option>IL</option>
        </select>
        <label for="stacked-remember" class="pure-checkbox">
            <input type="checkbox" id="stacked-remember" /> Remember me
        </label>
        <button type="submit" class="pure-button pure-button-primary">Sign in</button>
    </fieldset>
</form>

Aligned Form

To create an aligned form, add the pure-form-aligned classname to a <form> element alongside pure-form. In an aligned form, the labels are right-aligned against the form input controls, but on smaller screens revert to a stacked form.

This is a required field.
<form class="pure-form pure-form-aligned">
    <fieldset>
        <div class="pure-control-group">
            <label for="aligned-name">Username</label>
            <input type="text" id="aligned-name" placeholder="Username" />
            <span class="pure-form-message-inline">This is a required field.</span>
        </div>
        <div class="pure-control-group">
            <label for="aligned-password">Password</label>
            <input type="password" id="aligned-password" placeholder="Password" />
        </div>
        <div class="pure-control-group">
            <label for="aligned-email">Email Address</label>
            <input type="email" id="aligned-email" placeholder="Email Address" />
        </div>
        <div class="pure-control-group">
            <label for="aligned-foo">Supercalifragilistic Label</label>
            <input type="text" id="aligned-foo" placeholder="Enter something here..." />
        </div>
        <div class="pure-controls">
            <label for="aligned-cb" class="pure-checkbox">
                <input type="checkbox" id="aligned-cb" /> I&#x27;ve read the terms and conditions
            </label>
            <button type="submit" class="pure-button pure-button-primary">Submit</button>
        </div>
    </fieldset>
</form>

Multi-Column Form (with Pure Grids)

To create multi-column forms, include your form elements within a Pure Grid. Creating responsive multi-column forms (like the example below) requires Pure Responsive Grids to be present on the page.

Legend
<form class="pure-form pure-form-stacked">
    <fieldset>
        <legend>Legend</legend>
        <div class="pure-g">
            <div class="pure-u-1 pure-u-md-1-3">
                <label for="multi-first-name">First Name</label>
                <input type="text" id="multi-first-name" class="pure-u-23-24" />
            </div>
            <div class="pure-u-1 pure-u-md-1-3">
                <label for="multi-last-name">Last Name</label>
                <input type="text" id="multi-last-name" class="pure-u-23-24" />
            </div>
            <div class="pure-u-1 pure-u-md-1-3">
                <label for="multi-email">E-Mail</label>
                <input type="email" id="multi-email" class="pure-u-23-24" required="" />
            </div>
            <div class="pure-u-1 pure-u-md-1-3">
                <label for="multi-city">City</label>
                <input type="text" id="multi-city" class="pure-u-23-24" />
            </div>
            <div class="pure-u-1 pure-u-md-1-3">
                <label for="multi-state">State</label>
                <select id="multi-state" class="pure-input-1-2">
                    <option>AL</option>
                    <option>CA</option>
                    <option>IL</option>
                </select>
            </div>
        </div>
        <label for="multi-terms" class="pure-checkbox">
            <input type="checkbox" id="multi-terms" /> I&#x27;ve read the terms and conditions
        </label>
        <button type="submit" class="pure-button pure-button-primary">Submit</button>
    </fieldset>
</form>

Grouped Inputs

To group sets of text-based input elements, wrap them in a <fieldset> element with a pure-group classname. Grouped inputs work well for sign-up forms and look natural on mobile devices.

<form class="pure-form">
    <fieldset class="pure-group">
        <input type="text" class="pure-input-1-2" placeholder="Username" />
        <input type="text" class="pure-input-1-2" placeholder="Password" />
        <input type="email" class="pure-input-1-2" placeholder="Email" />
    </fieldset>
    <fieldset class="pure-group">
        <input type="text" class="pure-input-1-2" placeholder="A title" />
        <textarea class="pure-input-1-2" placeholder="Textareas work too"></textarea>
    </fieldset>
    <button type="submit" class="pure-button pure-input-1-2 pure-button-primary">Sign in</button>
</form>

Input Sizing

Input elements have fluid width sizes in a syntax that is similar to Pure Grids. You can apply a pure-input-* class to these elements.






<form class="pure-form">
    <input type="text" class="pure-input-1" placeholder=".pure-input-1" />
    <br />
    <input type="text" class="pure-input-2-3" placeholder=".pure-input-2-3" />
    <br />
    <input type="text" class="pure-input-1-2" placeholder=".pure-input-1-2" />
    <br />
    <input type="text" class="pure-input-1-3" placeholder=".pure-input-1-3" />
    <br />
    <input type="text" class="pure-input-1-4" placeholder=".pure-input-1-4" />
    <br />
</form>

You can control input sizing even further by wrapping them in grid containers. In the example below, the <input> elements have a pure-input-1 class, but are wrapped in a <div> with a specific grid class.

<form class="pure-form pure-g">
    <div class="pure-u-1-4">
        <input type="text" class="pure-input-1" placeholder=".pure-u-1-4" />
    </div>
    <div class="pure-u-3-4">
        <input type="text" class="pure-input-1" placeholder=".pure-u-3-4" />
    </div>
    <div class="pure-u-1-2">
        <input type="text" class="pure-input-1" placeholder=".pure-u-1-2" />
    </div>
    <div class="pure-u-1-2">
        <input type="text" class="pure-input-1" placeholder=".pure-u-1-2" />
    </div>
    <div class="pure-u-1-8">
        <input type="text" class="pure-input-1" placeholder=".pure-u-1-8" />
    </div>
    <div class="pure-u-1-8">
        <input type="text" class="pure-input-1" placeholder=".pure-u-1-8" />
    </div>
    <div class="pure-u-1-4">
        <input type="text" class="pure-input-1" placeholder=".pure-u-1-4" />
    </div>
    <div class="pure-u-1-2">
        <input type="text" class="pure-input-1" placeholder=".pure-u-1-2" />
    </div>
    <div class="pure-u-1-5">
        <input type="text" class="pure-input-1" placeholder=".pure-u-1-5" />
    </div>
    <div class="pure-u-2-5">
        <input type="text" class="pure-input-1" placeholder=".pure-u-2-5" />
    </div>
    <div class="pure-u-2-5">
        <input type="text" class="pure-input-1" placeholder=".pure-u-2-5" />
    </div>
    <div class="pure-u-1">
        <input type="text" class="pure-input-1" placeholder=".pure-u-1" />
    </div>
</form>

Required Inputs

To mark a form control as required, add the required attribute.

<form class="pure-form">
    <input type="email" placeholder="Requires an email" required="" />
</form>

Disabled Inputs

To disable a form control, add the disabled attribute.

<form class="pure-form">
    <input type="text" placeholder="Disabled input here..." disabled="" />
</form>

Read-Only Inputs

To make a form input read-only, add the readonly attribute. The difference between disabled and readonly is read-only inputs are still focusable. This allows people to interact with the input and select its text, whereas disabled controls are not interactive.

<form class="pure-form">
    <input type="text" value="Readonly input here..." readonly="" />
</form>

Rounded Inputs

To display a form control with rounded corners, add the pure-input-rounded classname.

<form class="pure-form">
    <input type="text" class="pure-input-rounded" />
    <button type="submit" class="pure-button">Search</button>
</form>

Checkboxes and Radios

To normalize and align checkboxes and radio inputs, add the pure-checkbox or pure-radio classname.

<form class="pure-form">
    <label for="checkbox-radio-option-one" class="pure-checkbox">
        <input type="checkbox" id="checkbox-radio-option-one" value="" /> Here&#x27;s option one.
    </label>
    <label for="checkbox-radio-option-two" class="pure-radio">
        <input type="radio" id="checkbox-radio-option-two" name="optionsRadios" value="option1" checked="" /> Here&#x27;s a radio button. You can choose this one..
    </label>
    <label for="checkbox-radio-option-three" class="pure-radio">
        <input type="radio" id="checkbox-radio-option-three" name="optionsRadios" value="option2" /> ..Or this one!
    </label>
</form>