Coding forms in Bootstrap 4

If you are familiar with Bootstrap 3, then you'll notice the CSS form classes are pretty much the same in version 4. The biggest change I see in forms for the new version is that each form group uses a <fieldset> tag instead of <div>. If you are new to Bootstrap forms, a basic form group is made up of a label and an input. It can also include help text, but that is optional. Let's jump right in by creating a generic form that uses a number of core components.

Setting up a form

At the very least, a form needs to be made up of one input and one button. Let's start with the basics and create a form following those requirements. Here's the code to get you started:

<form> <fieldset class="form-group"> <label>Text Label</label> ...

Get Learning Bootstrap 4 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.