4.1 Intro to Bootstrap



Bootstrap is the most popular HTML, CSS, and JavaScript framework in the world for building responsive, mobile-first websites.

A framework is pre-written code that aims to alleviate the overhead associated with common activities performed in web development. PRO: you don’t need to reinvent the wheel, the code is already written! CON: you have to learn OPC (other people’s code).

With Bootstrap, it is easy to quickly build responsive websites (meaning the function and look good on all device sizes). It is free and open-source. You can easily construct page layouts and use components — it contains CSS- and JavaScript-based templates for typography, forms, buttons, navigation, and other interface components. There are lots of pre-built classes to implement and then customize.

Downloading Bootstrap

To use Bootstrap in your project, follow these instructions:

Code Additions

Next, you will need to make some additions to your code to implement the Bootstrap framework.

  1. Adjust your the <head> of your HTML document so it looks like the code below. The two meta elements *must* come first in the head. Any other head content must come after these.
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
  3. Include the link for the Bootstrap CSS file in the <head> of your HTML file:
    <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet" />
  5. Add this right before your </body>. This is to include Javascript for interactive components like dropdowns, overlays, etc.
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <!-- Include Bootstrap components -->
    <script src="js/bootstrap.min.js"></script>

If you don't want to type any of this, you can use this starting project set up which includes all of the Bootstrap files (v4.5.2) and an HTML file.

Add general.css

You still need to add your own CSS file for any custom CSS you may need to do. Place this reference under the reference to the bootstrap CSS file:

<!-- the Bootstrap CSS -->
<link href="css/bootstrap.min.css" type="text/css" rel="stylesheet" />

<!-- please your general one here -->
<link rel="stylesheet" type="text/css" href="css/general.css" />