DEV Community

Reid Watson
Reid Watson

Posted on

HTML Styling Made Easy With Bootstrap

Bootstrap is a popular CSS framework that allows developers to easily implement a wide variety of HTML stylings. Bootstrap components such as navigation bars, search forms, a flexible grid system, among many others, can be used to make webpages more functional, aesthetically appealing, and responsive.
Below I've provided a quick tutorial on some basic Bootstrap implementations. As a whole, minimal setup and orientation is required, and you'll be surprised by how quickly you can start adding features and playing around with different stylings.
Essentially, Bootstrap is an enormous library of pre-written CSS classes that can be used to add stylings within your HTML document. To get started, you can either download Bootstrap directly or simply include this stylesheet link in the head of your HTML document.
image

Additionally, in order for some of the Bootstrap classes to be fully functional, you'll need to include some Bootstrap javascript and jQuery code at the bottom of your HTML body.
image

After these two steps, you'll have complete access to all of Bootstrap's classes, and can now start adding them in!

Navbar

Below I've mocked up a basic template for the Bootstrap navigation bar component. The navbar class generates a sleek banner-style navigation menu at the top of the page. Additionally, in order to support multiple browser window sizes, the navbar-toggler button and navbar-collapse class can be used as shown below to create a dropdown menu containing the menu options. This way, if your webpage is being viewed from a smartphone, the navbar automatically reformats to match the smaller screen size.
image

Sign-in Form

The HTML below is a template for a basic sign-in form that you might want to include as part of the landing page or home screen for you web application. Bootstrap conveniently provides the form class "form-signin" that builds out a basic form with text fields for email and password. The defaults all look fine, but there is plenty of room for customization within each individual form element.
image

Image Gallery
One of most powerful things about Bootstrap is the way in which it uses CSS classes to create a convenient grid system. The Bootstrap grid can be used to easily format different elements on your webpage, add spacing and organize your webpage's layout.

As shown below, the entire grid is held within a div with class name "container". Next, within the container you must create a div with the class name "row". Within this div, add separate divs with class names "col-column-width", each representing a column within the grid. Essentially, the "row" div has 12 column units of space. You can decide how many columns your table has, and how large or small they are compared to each other, by setting the number of units for each column when you define the column class. As shown below, I defined each column div (div class="col-lg-4"), with 4 units. I have three columns, each taking up 4 units in the grid, so each column will be equal in width.
You can then fill these columns with different elements. In this case, I chose to fill each column with images of various sizes, in order to create a basic image gallery page.

image

The above code renders this simple image table in the browser, and demonstrates how Bootstrap allows developers to add in a significant amount of styling with minimal code, directly within the HTML document.
image

The navbar, search form, and grid system, are just a few of the many different Bootstrap components you have to choose from. Hopefully, this short tutorial will inspire you to delve deeper into the Bootstrap library, and become a front end web design master!

Happy Coding!

Top comments (0)