Poliquin
Poliquin

Reputation: 2987

Bootstrap 3 form example

I am going through the basic form example on getbootstrap.com

It has the following code

<form role="form">
   <div class="form-group">
      <label for="exampleInputEmail1">Email address</label>
      <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
   </div>
   <div class="form-group">
      <label for="exampleInputPassword1">Password</label>
      <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
   </div>
</form>

Q1. Why is there a requirement for role="form" in <form role="form">?

Q2. Difference between input-group and form-group?

A2. Input-group places button or add-on on either side or both sides of an input (i.e. Left <> Right). form-group ,on the other hand, is top down. (i.e. label on top and text box on the bottom)

Q3. Is the for="exampleInputEmail1" in <label for="exampleInputEmail1"> required? This does not appear to be required in Bootstrap2.

Q4. Is the input type="email" (and input type="password") placed arbitrarily? I see some code that uses input type="text". Is it the same? If I require the input to be numbers only, could I have input type="numbers"?

Upvotes: 1

Views: 3248

Answers (1)

Jernej Novak
Jernej Novak

Reputation: 3283

Q1. This is ARIA http://www.w3.org/TR/wai-aria/roles WAI-ARIA, the Accessible Rich Internet Applications Suite, defines a way to make Web content and Web applications more accessible to people with disabilities

role="form" A region of the document that represents a collection of form-associated elements, some of which can represent editable values that can be submitted to a server for processing.

Q3. This is necessary to connect label with input.

Q4. The difference between different types will define how the input will be rendered. http://www.w3schools.com/html/html5_form_input_types.asp

Upvotes: 2

Related Questions