Coming from Lesson 3: Bootstrap Layouts and Grid System? Excellent! Now you’ll learn how to create interactive forms and use Bootstrap’s utility classes to enhance your layouts.
Bootstrap utilities are helper classes that make it easy to add common styling without writing custom CSS. They cover spacing, colors, borders, shadows, and more.
m-*
(margin), p-*
(padding) for consistent spacingtext-*
, bg-*
for text and background colorsborder
, border-*
for adding and styling bordersd-flex
, d-block
, d-inline
for controlling element visibility and layoutd-none
to hide an element.d-flex
, justify-content-*
, align-items-*
for flexible layoutsBootstrap provides powerful utility classes and form components that make building interactive interfaces simple and consistent.
form-control
and (form-select
for inputs and dropdowns)row
, col
for responsive form gridsis-valid
, is-invalid
for visual feedbackform-group
for organizing related inputsform-check
, form-switch
for checkboxes and togglesMost importantly, you will need the class .form-control and set the attribute type=
. (For example type=text
or type=checkbox
)
<!-- Spacing utilities -->
<div class="m-3 p-2">Content with margin and padding</div>
<!-- Form with grid layout -->
<form class="row g-3">
<div class="col-md-6">
<input type="text" class="form-control" placeholder="First Name">
</div>
<div class="col-md-6">
<input type="text" class="form-control" placeholder="Last Name">
</div>
</form>
Visit these links on W3 Schools. Read or skim the lessons. Click on the TRY IT YOURSELF button to see examples of the code.
After you finish, answer the questions in your group.
For this section, you will not use VSCode. Just use the TRY IT YOURSELF button. Be sure to make some changes to the code if you are curious as to what things do. Don’t be afraid to break the code, it will revert back if you refresh!
Visit these site links. Click on TRY IT YOURSELF. Get a general understanding of how it works. Then answer the questions at the end with your group.
Note: You may also visit getBootstrap.com for more on these concepts.
m-3
and p-2
mean?Now you have all the tools you need to create two interactive games using Bootstrap’s grid system and form components:
Requirements:
row
and col
) to display color swatchesCreate a Mad Libs-style word game where users fill in blanks to create funny stories.
mad-libs-game
You may work on this together, but it is not a group project. Each individual should have their own git repository and code.
If you finish early, as a challenge, you may work on your own project idea using Bootstrap utilities and forms. For example, you might make a mockup for a login screen. Or an address form for a shopping app.
Screen 1
Screen 2
Ready to collaborate on a group project? Continue to Lesson 5: CSS Grid Group Project to build the Color Sleuth game with your team using Bootstrap’s grid system!