Individual form controls receive styling, but without any required base class on the <form> or large changes in markup. Results in stacked, left-aligned labels on top of form controls.
<form>
<fieldset>
<legend>Legend</legend>
<label>Label name</label>
<inputtype="text"placeholder="Type something…">
<spanclass="help-block">Example block-level help text here.</span>
<labelclass="checkbox">
<inputtype="checkbox"> Check me out
</label>
<buttontype="submit"class="btn">Submit</button>
</fieldset>
</form>
Optional layouts
Included with Bootstrap are three optional form layouts for common use cases.
Search form
Add .form-search to the form and .search-query to the <input> for an extra-rounded text input.
Examples of standard form controls supported in an example form layout.
Inputs
Most common form control, text-based input fields. Includes support for all HTML5 types: text, password, datetime, datetime-local, date, month, time, week, number, email, url, search, tel, and color.
Requires the use of a specified type at all times.
<inputtype="text"placeholder="Text input">
Textarea
Form control which supports multiple lines of text. Change rows attribute as necessary.
<textarearows="3"></textarea>
Checkboxes and radios
Checkboxes are for selecting one or several options in a list while radios are for selecting one option from many.
Default (stacked)
<labelclass="checkbox">
<inputtype="checkbox"value="">
Option one is this and that—be sure to include why it's great
Heads up! In future versions, we'll be altering the use of these relative input classes to match our button sizes. For example, .input-large will increase the padding and font-size of an input.
Grid sizing
Use .span1 to .span12 for inputs that match the same sizes of the grid columns.
For multiple grid inputs per line, use the .controls-row modifier class for proper spacing. It floats the inputs to collapse white-space, sets the proper margins, and clears the float.
Present data in a form that's not editable without using actual form markup.
<spanclass="input-xlarge uneditable-input">Some value here</span>
Form actions
End a form with a group of actions (buttons). When placed within a .form-actions, the buttons will automatically indent to line up with the form controls.
Inline and block level support for help text that appears around form controls.
Inline help
<inputtype="text"><spanclass="help-inline">Inline help text</span>
Block help
<inputtype="text"><spanclass="help-block">A longer block of help text that breaks onto a new line and may extend beyond one line.</span>
Form control states
Provide feedback to users or visitors with basic feedback states on form controls and labels.
Input focus
We remove the default outline styles on some form controls and apply a box-shadow in its place for :focus.
<inputclass="input-xlarge"id="focusedInput"type="text"value="This is focused...">
Invalid inputs
Style inputs via default browser functionality with :invalid. Specify a type, add the required attribute if the field is not optional, and (if applicable) specify a pattern.
This is not available in versions of Internet Explorer 7-9 due to lack of support for CSS pseudo selectors.
<inputclass="span3"type="email"required>
Disabled inputs
Add the disabled attribute on an input to prevent user input and trigger a slightly different look.
Bootstrap includes validation styles for error, warning, info, and success messages. To use, add the appropriate class to the surrounding .control-group.
<divclass="control-group warning">
<labelclass="control-label"for="inputWarning">Input with warning</label>
<divclass="controls">
<inputtype="text"id="inputWarning">
<spanclass="help-inline">Something may have gone wrong</span>
</div>
</div>
<divclass="control-group error">
<labelclass="control-label"for="inputError">Input with error</label>
<divclass="controls">
<inputtype="text"id="inputError">
<spanclass="help-inline">Please correct the error</span>
</div>
</div>
<divclass="control-group info">
<labelclass="control-label"for="inputInfo">Input with info</label>
<divclass="controls">
<inputtype="text"id="inputInfo">
<spanclass="help-inline">Username is already taken</span>
</div>
</div>
<divclass="control-group success">
<labelclass="control-label"for="inputSuccess">Input with success</label>
<divclass="controls">
<inputtype="text"id="inputSuccess">
<spanclass="help-inline">Woohoo!</span>
</div>
</div>
Get Email Updates
To receive email updates about this page, enter your email address: