Bootstrap provides with predefined styling for all the form controls. <input>, <textarea>, and <select> elements when applied with class .form-control, as we have done in the below example, gets the width assigned as 100%.
2. Bootstrap Form – Thumb Rules
There are some thumb rules we must follow while creating an HTML form –
- We must always specify the role attribute, like <form role = “form” …>
- Must wrap all the labels and form controls within .form-group class, like <div class=”form-group”>
- Add class .form-control to all textual <input>, <textarea>, and <select> elements
- For an inline form, add class .form-inline to the <form> element
- For horizontal form, add class .form-horizontal to the <form> element and .control-label to all <label> elements