Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • BS5 Tutorial
  • BS5 Interview Questions
  • BS5 Layout
  • BS5 Content
  • BS5 Components
  • BS5 Helpers
  • BS5 Utilities
  • BS4 Tutorial
  • BS Tutorial
  • Bootstrap Cheatsheet
  • Tailwind
  • CSS Frameworks
  • HTML Formatter
Open In App
Next Article:
Explain the steps for creating basic or vertical forms using Bootstrap
Next article icon

How to create a vertical or basic form using Bootstrap ?

Last Updated : 05 Jun, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

Forms are used on almost every website that you visit. It is generally used to collect data from the users. It consists of various interactive controls that enable users to input the data. These controls are wrapped in the <form> tag and also can be designed or styled according to the need by setting different attributes of the controls, to different values.

Some of the major form controls are:

  • Text Fields: They are single-lined fields, allowing to input of text of a single line only.
  • Password Fields: They are special text fields, which represent special characters such as an asterisk or a bullet, instead of what the user types.
  • Textarea: They are multi-lined fields, allowing to input of text of multiple lines.
  • Checkboxes: Checkboxes enable you to select multiple options from a number of choices.
  • Radio Buttons: Radio buttons are also used to select from a number of choices but here, only one button can be selected at a time.
  • Submit Buttons: It is a button used for the submission of the form data, entered by the user.

They can be integrated into the forms as per the requirements.

Bootstrap provides the following 3 types of form layouts :

  1. Vertical Forms (Default)
  2. Horizontal Forms
  3. Inline Forms

In this article, we will be learning to create the basic vertical forms.

How to create vertical or basic form in bootstrap?

  • To include this form into your website by making use of bootstrap, you just need to include the following jquery and bootstrap  libraries, as scripts in your HTML code.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>

  • Include the following stylesheet link of the bootstrap in the head of the HTML document, which will enable us to use various classes of bootstrap for styling the form and its controls.

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">

  • Include <form> tag in the body of the code for creating the form and to wrap all the form controls you want to include in your form.
<form>     <div class="form-group">         <label>User Name</label>         <input class="form-control"              type="text"              placeholder="Enter your User Name">     </div>      <div class="form-group">         <label>Password</label>         <input class="form-control"              type="password"              placeholder="Enter your password">     </div> </form>

Here,

  • <label> tag is used to include the label form-control.
  • class="form-group" is used to adjust the spacing between the various form controls.
  • class="form-control" is used to style the form controls, like their appearance.

Example 1: In this example, we are creating vertical forms using Bootstrap.

HTML
<!DOCTYPE html> <html> <head>     <title>Vertical forms Example</title>     <link rel="stylesheet"            href= "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">     <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js">     </script>     <script src= "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js">     </script> </head>  <body>     <div class="container" style="color:green">         <h1>GeeksforGeeks</h1>     </div>     <div class="container">         <h4>Vertical Form -> Example:1</h4>         <form>             <div class="form-group">                 <label>User Name</label>                 <input class="form-control" type="text"                         placeholder="Enter your User Name">             </div>             <div class="form-group">                 <label>Password</label>                 <input class="form-control" type="password"                         placeholder="Enter your password">             </div>             <div class="container">                 <button type="button" class="btn btn-success">                     Login                 </button>                 <button type="button" class="btn btn-secondary">                     Register                 </button>             </div>         </form>     </div> </body> </html> 

Output:

As you can see in the output, a basic form is created, having interactive form controls i.e. two labels, one text field, and one password field to enter the data i.e. name and password, and 2 buttons i.e. login and register.

Example 2: In this example, we have created more options in the vertical form.

HTML
<!DOCTYPE html> <html> <head>     <title>Vertical forms Example</title>     <link rel="stylesheet"            href= "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">     <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js">     </script>     <script src= "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js">     </script> </head>  <body>     <div class="container" style="color:green">         <h1>GeeksforGeeks</h1>     </div>     <div class="container">         <h4>Vertical Form -> Example:2</h4>         <form>             <div class="form-group">                 <label>Name</label>                 <input class="form-control" type="text"                         placeholder="Enter your Name">             </div>              <div class="form-group">                 <label>Gender</label>                 <div class="form-check">                     <input class="form-check-input" type="radio"                             name="exampleRadios" id="exampleRadios1"                            value="option1" checked>                     <label class="form-check-label" for="exampleRadios1">                         Male                     </label>                 </div>                  <div class="form-check">                     <input class="form-check-input" type="radio"                             name="exampleRadios" id="exampleRadios1"                            value="option1" checked>                     <label class="form-check-label" for="exampleRadios1">                         Female                     </label>                 </div>                 <div class="form-check">                     <input class="form-check-input" type="radio"                             name="exampleRadios" id="exampleRadios1"                            value="option1" checked>                     <label class="form-check-label" for="exampleRadios1">                         Others                     </label>                 </div>             </div>             <div class="form-group">                 <label>Skills</label>                 <div class="form-check">                     <input class="form-check-input" type="checkbox"                             value="" id="defaultCheck1">                     <label class="form-check-label" for="defaultCheck1">                         Web Development                     </label>                 </div>                 <div class="form-check">                     <input class="form-check-input" type="checkbox"                             value="" id="defaultCheck1">                     <label class="form-check-label" for="defaultCheck1">                         Android Development                     </label>                 </div>                 <div class="form-check">                     <input class="form-check-input" type="checkbox"                             value="" id="defaultCheck1">                     <label class="form-check-label" for="defaultCheck1">                         DSA                     </label>                 </div>             </div>             <div class="container">                 <button type="button" class="btn btn-success">                     Submit                 </button>                 <button type="button" class="btn btn-secondary">                     Clear                 </button>             </div>         </form>     </div> </body> </html> 

Output:

In this output form, radio buttons are included, enabling or forcing the user to choose only one gender option from the  list and Checkboxes are also introduced, enabling the user to select multiple skills and that too in a vertical form(default).


Next Article
Explain the steps for creating basic or vertical forms using Bootstrap

B

bhawnaatrish
Improve
Article Tags :
  • Web Technologies
  • HTML
  • Bootstrap
  • HTML-Questions
  • Bootstrap-Questions

Similar Reads

  • Explain the steps for creating basic or vertical forms using Bootstrap
    Bootstrap is an open-source CSS framework that is used for building responsive websites. It has HTML, CSS, and JS frameworks for developing user-friendly and responsive websites. As of August 2021, Bootstrap is the tenth most starred project on GitHub. The website has ready-made templates given alon
    4 min read
  • How to create a Simple Footer using Bootstrap 5 ?
    Bootstrap 5 Footers can be used for displaying Contact links, Social media links, Service links, Company Logos, and other sections. The <footer> tag can be used with built-in classes for making the responsive footer layout. For accomplishing this task, there are 2 approaches, i.e., by using Bo
    4 min read
  • How to create forms using Twitter Bootstrap ?
    Every website that you visit will have some sort of form in it to collect data from the users. A Form consists of input fields that allow the user to enter the data. Bootstrap provides us with a very easy way to add customizable & responsive forms to our web pages.  In this article, we will lear
    5 min read
  • How to create a web page using Bootstrap ?
    Bootstrap is an open-source CSS framework for creating a responsive and customizable frontend for websites and web applications. Using Bootstrap's grid system one can easily create a web page very fast. Any webpage these days needs to have a navbar for user navigation, some content & a form for
    6 min read
  • How to create a form within dropdown menu using Bootstrap ?
    A Dropdown menu is used to allow the user to choose the content from the menu as per their requirement and it is used to save screen space and avoid the long scrolling of the web pages. In web design, we often come in a scenario where we need to create a form within the dropdown menu to get some use
    3 min read
  • How to Create a Bootstrap Form Validation ?
    A Bootstrap Form Validation ensures that user input complies with established standards before submission, improves the user experience, and minimizes server-side processing for incorrect inputs. We can add client-side validation to their forms by using two different methods including Bootstrap buil
    3 min read
  • How to Create a Basic Two-Column Layout using Bootstrap 5 ?
    To create a basic two-column layout using Bootstrap, first, we have to enclose your content within a container, then create two divs with classes like col or col-xx, where xx represents the breakpoint for responsive behavior. Place your content inside these columns, and Bootstrap will handle the lay
    3 min read
  • How to Create Form Layouts with Bootstrap ?
    Form Layouts in Bootstrap refer to the arrangement and presentation of form elements within a web page. To create Form Layouts with Bootstrap, utilize grid system classes to structure forms horizontally or vertically, and enhance them with input groups, inline forms, and responsive designs for impro
    5 min read
  • How to write a form in different line using Bootstrap ?
    Bootstrap is an open-source front-end framework for developing standard & decorative websites or web applications that are fast and user-friendly. Bootstrap includes templates based on HTML and CSS for tables, forms, buttons, etc. Bootstrap also uses JavaScript and helps us to create responsive
    2 min read
  • How to create a basic button group in Bootstrap ?
    Button: The .btn classes are used with the <button> element to create the basic button using Bootstrap. The buttons in bootstrap are used in forms, dialogs, etc. Button Groups in Bootstrap: In Bootstrap, button groups has group of buttons together on a single line. Button group is created usin
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences