Bootstrap 3
An overview of Bootstrap, how to download and use, basic templates and examples, and more.
Download
Bootstrap (currently v3.4.1) has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.
Bootstrap
Compiled and minified CSS, JavaScript, and fonts. No docs or original source files are included.
Source code
Source Less, JavaScript, and font files, along with our docs. Requires a Less compiler and some setup.
Sass
Bootstrap ported from Less to Sass for easy inclusion in Rails, Compass, or Sass-only projects.
BootstrapCDN
The folks over at StackPath graciously provide CDN support for Bootstrap's CSS and JavaScript. Just use these BootstrapCDN links.
<!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"> <!-- Optional theme --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"> <!-- Latest compiled and minified JavaScript --> <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
Install with Bower
You can also install and manage Bootstrap's Less, CSS, JavaScript, and fonts using Bower:
bower install bootstrap
Install with npm
You can also install Bootstrap using npm:
npm install bootstrap@3
require('bootstrap')
will load all of Bootstrap's jQuery plugins onto the jQuery object. The bootstrap
module itself does not export anything. You can manually load Bootstrap's jQuery plugins individually by loading the /js/*.js
files under the package's top-level directory.
Bootstrap's package.json
contains some additional metadata under the following keys:
-
less
- path to Bootstrap's main Less source file -
style
- path to Bootstrap's non-minified CSS that's been precompiled using the default settings (no customization)
Install with Composer
You can also install and manage Bootstrap's Less, CSS, JavaScript, and fonts using Composer:
composer require twbs/bootstrap
Autoprefixer required for Less/Sass
Bootstrap uses Autoprefixer to deal with CSS vendor prefixes. If you're compiling Bootstrap from its Less/Sass source and not using our Gruntfile, you'll need to integrate Autoprefixer into your build process yourself. If you're using precompiled Bootstrap or using our Gruntfile, you don't need to worry about this because Autoprefixer is already integrated into our Gruntfile.
What's included
Bootstrap is downloadable in two forms, within which you'll find the following directories and files, logically grouping common resources and providing both compiled and minified variations.
jQuery required
Please note that all JavaScript plugins require jQuery to be included, as shown in the starter template. Consult our bower.json
to see which versions of jQuery are supported.
Precompiled Bootstrap
Once downloaded, unzip the compressed folder to see the structure of (the compiled) Bootstrap. You'll see something like this:
bootstrap/ ├── css/ │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ ├── bootstrap.min.css.map │ ├── bootstrap-theme.css │ ├── bootstrap-theme.css.map │ ├── bootstrap-theme.min.css │ └── bootstrap-theme.min.css.map ├── js/ │ ├── bootstrap.js │ └── bootstrap.min.js └── fonts/ ├── glyphicons-halflings-regular.eot ├── glyphicons-halflings-regular.svg ├── glyphicons-halflings-regular.ttf ├── glyphicons-halflings-regular.woff └── glyphicons-halflings-regular.woff2
This is the most basic form of Bootstrap: precompiled files for quick drop-in usage in nearly any web project. We provide compiled CSS and JS (bootstrap.*
), as well as compiled and minified CSS and JS (bootstrap.min.*
). CSS source maps (bootstrap.*.map
) are available for use with certain browsers' developer tools. Fonts from Glyphicons are included, as is the optional Bootstrap theme.
Bootstrap source code
The Bootstrap source code download includes the precompiled CSS, JavaScript, and font assets, along with source Less, JavaScript, and documentation. More specifically, it includes the following and more:
bootstrap/ ├── less/ ├── js/ ├── fonts/ ├── dist/ │ ├── css/ │ ├── js/ │ └── fonts/ └── docs/ └── examples/
The less/
, js/
, and fonts/
are the source code for our CSS, JS, and icon fonts (respectively). The dist/
folder includes everything listed in the precompiled download section above. The docs/
folder includes the source code for our documentation, and examples/
of Bootstrap usage. Beyond that, any other included file provides support for packages, license information, and development.
Compiling CSS and JavaScript
Bootstrap uses Grunt for its build system, with convenient methods for working with the framework. It's how we compile our code, run tests, and more.
Installing Grunt
To install Grunt, you must first download and install node.js (which includes npm). npm stands for node packaged modules and is a way to manage development dependencies through node.js.
Then, from the command line:- Install
grunt-cli
globally withnpm install -g grunt-cli
. - Navigate to the root
/bootstrap/
directory, then runnpm install
. npm will look at thepackage.json
file and automatically install the necessary local dependencies listed there.
When completed, you'll be able to run the various Grunt commands provided from the command line.
Available Grunt commands
grunt dist
(Just compile CSS and JavaScript)
Regenerates the /dist/
directory with compiled and minified CSS and JavaScript files. As a Bootstrap user, this is normally the command you want.
grunt watch
(Watch)
Watches the Less source files and automatically recompiles them to CSS whenever you save a change.
grunt test
(Run tests)
Runs JSHint and runs the QUnit tests in real browsers thanks to Karma.
grunt docs
(Build & test the docs assets)
Builds and tests CSS, JavaScript, and other assets which are used when running the documentation locally via bundle exec jekyll serve
.
grunt
(Build absolutely everything and run tests)
Compiles and minifies CSS and JavaScript, builds the documentation website, runs the HTML5 validator against the docs, regenerates the Customizer assets, and more. Requires Jekyll. Usually only necessary if you're hacking on Bootstrap itself.
Troubleshooting
Should you encounter problems with installing dependencies or running Grunt commands, first delete the /node_modules/
directory generated by npm. Then, rerun npm install
.
Basic template
Start with this basic HTML template, or modify these examples. We hope you'll customize our templates and examples, adapting them to suit your needs.
Copy the HTML below to begin working with a minimal Bootstrap document.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <title>Bootstrap 101 Template</title> <!-- Bootstrap --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <h1>Hello, world!</h1> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script> </body> </html>
Examples
Build on the basic template above with Bootstrap's many components. We encourage you to customize and adapt Bootstrap to suit your individual project's needs.
Get the source code for every example below by downloading the Bootstrap repository. Examples can be found in the docs/examples/
directory.