Description :
.form-inline
is used to make the form horizontal and class .sr-only
is used to make the label text invisible.
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Bootstrap form Example</title> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Horizontal form</h2> <form class="form-inline" role="form"> <div class="form-group"> <label class="sr-only" for="email">UserName:</label> <input type="text" class="form-control" id="uname" placeholder="Enter UserName"> </div> <div class="form-group"> <label class="sr-only" for="pwd">Password:</label> <input type="password" class="form-control" id="pwd" placeholder="Enter password"> </div> <div class="checkbox"> <label><input type="checkbox"> Remember me</label> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> </body> </html>
Description :
.container
class is used to contain the input controls and after that simple form is used.class .form-group
is used to make group of form controls like label and inputs.
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Bootstrap form Example</title> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Vertical form</h2> <form role="form"> <div class="form-group"> <label for="email">UserName:</label> <input type="text" class="form-control" id="uname" placeholder="Enter UserName"> </div> <div class="form-group"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd" placeholder="Enter password"> </div> <div class="checkbox"> <label><input type="checkbox"> Remember me</label> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> </body> </html>