twitter-bootstrap

Forms

Basic form

Form controls have some default styling without using any special classes.

However labels and controls can be wrapped in .form-group tags for optimum spacing.

<form>
  <div class="form-group">
    <label for="input-email">Email address</label>
    <input type="email" class="form-control" id="input-email" placeholder="Email">
  </div>
  <div class="form-group">
    <label for="input-password">Password</label>
    <input type="password" class="form-control" id="input-password" placeholder="Password">
  </div>
  <button type="submit" class="btn btn-default">Submit</button>
</form>

Read-only and disabled inputs

Add the readonly attribute to prevent user input. A readonly field can’t be edited

<input class="form-control" type="text" placeholder="Readonly input here…" readonly>

Add the disabled attribute to disable an input field. A disbled field can’t be edited either. The cursor changes to make it more noticeable.

<input class="form-control" id="disabledInput" type="text" placeholder="Disabled input here..." disabled>

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow