Etiam porta sem malesuada magna mollis euismod. Maecenas faucibus mollis interdum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
Bootstrap is a responsive frontend toolkit from Twitter designed to kickstart web development, complete with core HTML, CSS, and JS for grids, type, forms, navigation, and many more components.
Download on GitHub Currently v2.0.0
Engineers at Twitter have historically used almost any library they were familiar with to meet front-end requirements. Bootstrap began as an answer to the challenges that presented. With the help of many awesome folks, Bootstrap has grown significantly.
Read more on dev.twitter.com ›
Bootstrap is tested and supported in major modern browsers like Chrome, Safari, Internet Explorer, and Firefox.
Bootstrap comes complete with compiled CSS, uncompiled, and example templates.
Need some quick templates? Check out these basic examples we've put together:
The default grid system provided as part of Bootstrap is a 940px-wide, 12-column grid.
It also has three responsive variations for various devices and resolutions: phone, tablet, and large widescreen desktops.
<div class="row"> <div class="span4">...</div> <div class="span8">...</div> </div>
As shown here, a basic layout can be created with two "columns," each spanning a number of the 12 foundational columns we defined as part of our grid system.
With the static (non-fluid) grid system in Bootstrap, nesting is easy. To nest your content, just add a new .row
and set of .span*
columns within an existing .span*
column.
<div class="row"> <div class="span12"> Level 1 of column <div class="row"> <div class="span6">Level 2</div> <div class="span6">Level 2</div> </div> </div> </div>
Variable | Default value | Description |
---|---|---|
@gridColumns |
16 | The number of columns within the grid |
@gridColumnWidth |
40px | The width of each column within the grid |
@gridGutterWidth |
20px | The negative space between each column |
@siteWidth |
Computed sum of all columns and gutters | We use some basic match to count the number of columns and gutters and set the width of the .fixed-container() mixin. |
Built into Bootstrap are a handful of variables for customizing the default 940px grid system, documented above. All variables for the grid are stored in mixins.less.
Modifying the grid means changing the three @grid*
variables and recompiling Bootstrap. Change the grids in the preboot.less file and use one of the four ways documented to recompile.
Customization of the grid only works at the default level, the 940px grid. To maintain the responsive aspects of Bootstrap, you'll also have to customize the grids in responsive.less.
The default and simple 940px-wide, centered layout for just about any website or page provided by a single <div.container>
.
<body> <div class="container"> ... </div> </body>
An alternative, flexible fluid page structure with min- and max-widths and a left-hand sidebar. Great for apps and docs.
<body> <div class="container-fluid"> <div class="sidebar"> ... </div> <div class="content"> ... </div> </div> </body>
Under 480px Smartphones | 480px to 768px Portrait tablet | 768px to 940px Landscape tablet | 940px and up Default | 1170px and up Large screens |
With these media queries, Bootstrap provides developers with the core tools necessary to develop responsively on the web for the world's most common devices and resolutions.
Bootstrap doesn't automatically include these media queries, but understanding and adding them is very easy and requires minimal setup. You have a few options for including the responsive features of Bootstrap:
Why not just include it? Truth be told, not everything needs to be responsive. Instead of encouraging developers to remove this feature, we figure it best to enable it.
// Landscape phones and down @media (max-width: 480px) { ... } // Landscape phone to portrait tablet @media (min-width: 480px) and (max-width: 768px) { ... } // Portrait tablet to landscape and desktop @media (min-width: 768px) and (max-width: 940px) { ... } // Large desktop @media (min-width: 1210px) { .. }
The entire typographic grid is based on two Less variables in our preboot.less file: @baseFontSize
and @baseLineHeight
. The first is the base font-size used throughout and the second is the base line-height.
We use those variables, and some math, to create the margins, paddings, and line-heights of all our type and more.
Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam id dolor id nibh ultricies vehicula ut id elit.
Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec sed odio dui.
Element | Description | Usage |
---|---|---|
<strong>
|
For emphasizing a snippet of text with important | None |
<em>
|
For emphasizing a snippet of text with stress | None |
<abbr>
|
Wraps abbreviations and acronyms to show the expanded version on hover |
Include optional title for expanded text
|
<address>
|
For contact information for its nearest ancestor or the entire body of work |
Preserve formatting by ending all lines with <br>
|
Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Maecenas faucibus mollis interdum. Nulla vitae elit libero, a pharetra augue.
Note: Feel free to use <b>
and <i>
in HTML5, but their usage has changed a bit. <b>
is meant to highlight words or phrases without conveying additional importance while <i>
is mostly for voice, technical terms, etc.
Here are two examples of how the <address>
tag can be used:
Abbreviations are styled with uppercase text and a light dotted bottom border. They also have a help cursor on hover so users have extra indication something will be shown on hover.
HTML is the best thing since sliced bread.
An abbreviation of the word attribute is attr.
To include a blockquote, wrap <blockquote>
around <p>
and <small>
tags. Use the <small>
element to cite your source and you'll get an em dash —
before it.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante venenatis dapibus posuere velit aliquet.
Dr. Julius Hibbert
<blockquote> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante venenatis dapibus posuere velit aliquet.</p> <small>Dr. Julius Hibbert</small> </blockquote>
<ul>
<ul.unstyled>
<ol>
<dl>
Element | Result |
---|---|
<code> |
In a line of text like this, your wrapped code will look like this <html> element. |
<pre> |
<div> <h1>Heading</h1> <p>Something right here...</p> </div> Note: Be sure to keep code within |
<pre class="prettyprint"> |
Using the google-code-prettify library, you're blocks of code get a slightly different visual style and automatic syntax highlighting. You can also add an additional class to add line numbers. <div> <h1>Heading</h1> <p>Something right here...</p> </div> <div> <h1>Heading</h1> <p>Something right here...</p> </div> Download google-code-prettify and view the readme for how to use. |
Labels | Markup |
---|---|
Default |
<span class="label">Default</span>
|
New |
<span class="label success">New</span>
|
Warning |
<span class="label warning">Warning</span>
|
Important |
<span class="label important">Important</span>
|
Notice |
<span class="label notice">Notice</span>
|
Tag | Description |
---|---|
<table>
|
Wrapping element for displaying data in a tabular format |
<thead>
|
Container element for table header rows (<tr> ) to label table columns
|
<tbody>
|
Container element for table rows (<tr> ) in the body of the table
|
<tr>
|
Container element for a set of table cells (<td> or <th> ) that appears on a single row
|
<td>
|
Default table cell |
<th>
|
Special table cell for column (or row, depending on scope and placement) labels Must be used within a <thead>
|
<caption>
|
Description or summary of what the table holds, especially useful for screen readers |
<table> <thead> <tr> <th>...</th> <th>...</th> </tr> </thead> <tbody> <tr> <td>...</td> <td>...</td> </tr> </tbody> </table>
All tables will be automatically styled with only the essential borders to ensure readability and maintain structure. No need to add extra classes or attributes.
# | First Name | Last Name | Language |
---|---|---|---|
1 | Some | One | English |
2 | Joe | Sixpack | English |
3 | Stu | Dent | Code |
<table> ... </table>
Get a little fancy with your tables by adding zebra-striping—just add the .zebra-striped
class.
# | First Name | Last Name | Language |
---|---|---|---|
1 | Some | One | English |
2 | Joe | Sixpack | English |
3 | Stu | Dent | Code |
Note: Zebra-striping is a progressive enhancement not available for older browsers like IE8 and below.
<table class="zebra-striped"> ... </table>
Taking the previous example, we improve the usefulness of our tables by providing sorting functionality via jQuery and the Tablesorter plugin. Click any column’s header to change the sort.
# | First Name | Last Name | Language |
---|---|---|---|
1 | Your | One | English |
2 | Joe | Sixpack | English |
3 | Stu | Dent | Code |
<script src="js/jquery/jquery.tablesorter.min.js"></script> <script > $(function() { $("table#sortTableExample").tablesorter({ sortList: [[1,0]] }); }); </script> <table class="zebra-striped"> ... </table>
With 2.0, we now have four types of forms to choose from:
As a convention, buttons are used for actions while links are used for objects. For instance, "Download" could be a button and "recent activity" could be a link.
All buttons default to a light gray style, but a number of functional classes can be applied for different color styles. These classes include a blue .primary
class, a light-blue .info
class, a green .success
class, and a red .danger
class.
Button styles can be applied to anything with the .btn
applied. Typically you’ll want to apply these to only <a>
, <button>
, and select <input>
elements. Here’s how it looks:
Fancy larger or smaller buttons? Have at it!
For buttons that are not active or are disabled by the app for one reason or another, use the disabled state. That’s .disabled
for links and :disabled
for <button>
elements.
Display thumbnails of varying sizes on pages with a low HTML footprint and minimal styles.
Thumbnails in the .media-grid
can be any size, but they work best when mapped directly to the built-in Bootstrap grid system. Image widths like 90, 210, and 330 combine with a few pixels of padding to equal the .span2
, .span4
, and .span6
column sizes.
Media grids are easy to use and rather simple on the markup side. Their dimensions are purely based on the size of the images included.
<ul class="media-grid"> <li> <a href="#"> <img class="thumbnail" src="http://placehold.it/330x230" alt=""> </a> </li> <li> <a href="#"> <img class="thumbnail" src="http://placehold.it/330x230" alt=""> </a> </li> </ul>
.alert-message
One-line messages for highlighting the failure, possible failure, or success of an action. Particularly useful for forms.
<div class="alert-message warning"> <a class="close" href="#">×</a> <p><strong>Holy guacamole!</strong> Best check yo self, you’re not looking too good.</p> </div>
.alert-message.block-message
For messages that require a bit of explanation, we have paragraph style alerts. These are perfect for bubbling up longer error messages, warning a user of a pending action, or just presenting information for more emphasis on the page.
<div class="alert-message block-message warning"> <a class="close" href="#">×</a> <p><strong>Holy guacamole! This is a warning!</strong> Best check yo self, you’re not looking too good. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p> <div class="alert-actions"> <a class="btn small" href="#">Take this action</a> <a class="btn small" href="#">Or do this</a> </div> </div>
Modals—dialogs or lightboxes—are great for contextual actions in situations where it’s important that the background context be maintained.
One fine body…
Twipsies are super useful for aiding a confused user and pointing them in the right direction.
Lorem ipsum dolar sit amet illo error ipsum veritatis aut iste perspiciatis iste voluptas natus illo quasi odit aut natus consequuntur consequuntur, aut natus illo voluptatem odit perspiciatis laudantium rem doloremque totam voluptas. Voluptasdicta eaque beatae aperiam ut enim voluptatem explicabo explicabo, voluptas quia odit fugit accusantium totam totam architecto explicabo sit quasi fugit fugit, totam doloremque unde sunt sed dicta quae accusantium fugit voluptas nemo voluptas voluptatem rem quae aut veritatis quasi quae.
Use popovers to provide subtextual information to a page without affecting layout.
Etiam porta sem malesuada magna mollis euismod. Maecenas faucibus mollis interdum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
Integrating javascript with the Bootstrap library is super easy. Below we go over the basics and provide you with some awesome plugins to get you started!
Bring some of Bootstrap's primary components to life with new custom plugins that work with jQuery and Ender. We encourage you to extend and modify them to fit your specific development needs.
File | Description |
---|---|
bootstrap-modal.js | Our Modal plugin is a super slim take on the traditional modal js plugin! We took special care to include only the bare functionality that we require at twitter. |
bootstrap-alerts.js | The alert plugin is a super tiny class for adding close functionality to alerts. |
bootstrap-dropdown.js | This plugin is for adding dropdown interaction to the bootstrap navbar or tabbed navigations. |
bootstrap-scrollspy.js | The ScrollSpy plugin is for adding an auto updating nav based on scroll position to the bootstrap navbar. |
bootstrap-tabs.js | This plugin adds quick, dynamic tab and pill functionality for cycling through local content. |
bootstrap-twipsy.js | Based on the excellent jQuery.tipsy plugin written by Jason Frame; twipsy is an updated version, which doesn't rely on images, uses css3 for animations, and data-attributes for local title storage! |
bootstrap-popover.js | The popover plugin provides a simple interface for adding popovers to your application. It extends the boostrap-twipsy.js plugin, so be sure to grab that file as well when including popovers in your project! |
Nope! Bootstrap is designed first and foremost to be a CSS library. This javascript provides a basic interactive layer on top of the included styles.
However, for those who do need javascript, we've provided the plugins above to help you understand how to integrate Bootstrap with javascript and to give you a quick, lightweight option for the basic functionality right away.
For more information and to see some live demos, please refer to our plugin documentation page.
Bootstrap was built with Preboot, an open-source pack of mixins and variables to be used in conjunction with Less, a CSS preprocessor for faster and easier web development.
Check out how we used Preboot in Bootstrap and how you can make use of it should you choose to run Less on your next project.
Use this option to make full use of Bootstrap’s Less variables, mixins, and nesting in CSS via javascript in your browser.
<link rel="stylesheet/less" href="less/bootstrap.less" media="all" /> <script src="js/less-1.1.3.min.js"></script>
Not feeling the .js solution? Try the Less Mac app or use Node.js to compile when you deploy your code.
Here are some of the highlights of what’s included in Twitter Bootstrap as part of Bootstrap. Head over to the Bootstrap website or Github project page to download and learn more.
Variables in Less are perfect for maintaining and updating your CSS headache free. When you want to change a color value or a frequently used value, update it in one spot and you’re set.
// Links @linkColor: #8b59c2; @linkColorHover: darken(@linkColor, 10); // Grays @black: #000; @grayDark: lighten(@black, 25%); @gray: lighten(@black, 50%); @grayLight: lighten(@black, 70%); @grayLighter: lighten(@black, 90%); @white: #fff; // Accent Colors @blue: #08b5fb; @green: #46a546; @red: #9d261d; @yellow: #ffc40d; @orange: #f89406; @pink: #c3325f; @purple: #7a43b6; // Baseline grid @basefont: 13px; @baseline: 18px;
Less also provides another style of commenting in addition to CSS’s normal /* ... */
syntax.
// This is a comment /* This is also a comment */
Mixins are basically includes or partials for CSS, allowing you to combine a block of code into one. They’re great for vendor prefixed properties like box-shadow
, cross-browser gradients, font stacks, and more. Below is a sample of the mixins that are included with Bootstrap.
#font { .shorthand(@weight: normal, @size: 14px, @lineHeight: 20px) { font-size: @size; font-weight: @weight; line-height: @lineHeight; } .sans-serif(@weight: normal, @size: 14px, @lineHeight: 20px) { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: @size; font-weight: @weight; line-height: @lineHeight; } ... }
#gradient { ... .vertical (@startColor: #555, @endColor: #333) { background-color: @endColor; background-repeat: repeat-x; background-image: -khtml-gradient(linear, left top, left bottom, from(@startColor), to(@endColor)); // Konqueror background-image: -moz-linear-gradient(@startColor, @endColor); // FF 3.6+ background-image: -ms-linear-gradient(@startColor, @endColor); // IE10 background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, @startColor), color-stop(100%, @endColor)); // Safari 4+, Chrome 2+ background-image: -webkit-linear-gradient(@startColor, @endColor); // Safari 5.1+, Chrome 10+ background-image: -o-linear-gradient(@startColor, @endColor); // Opera 11.10 background-image: linear-gradient(@startColor, @endColor); // The standard } ... }
Get fancy and perform some math to generate flexible and powerful mixins like the one below.
// Griditude @gridColumns: 16; @gridColumnWidth: 40px; @gridGutterWidth: 20px; @siteWidth: (@gridColumns * @gridColumnWidth) + (@gridGutterWidth * (@gridColumns - 1)); // Make some columns .columns(@columnSpan: 1) { width: (@gridColumnWidth * @columnSpan) + (@gridGutterWidth * (@columnSpan - 1)); }
After modifying the .less
files in /lib/, you'll need to recompile them in order to regenerate the bootstrap-*.*.*.css and bootstrap-*.*.*.min.css files. If you're submitting a pull request to GitHub, you must always recompile.
Method | Steps |
---|---|
Node with makefile |
Install the less command line compiler with npm by running the following command: $ npm install lessc Once installed just run Additionally, if you have watchr installed, you may run |
Javascript |
Download the latest Less.js and include the path to it (and Bootstrap) in the <link rel="stylesheet/less" href="/path/to/bootstrap.less"> <script src="/path/to/less.js"></script> To recompile the .less files, just save them and reload your page. Less.js compiles them and stores them in local storage. |
Command line |
If you already have the less command line tool installed, simply run the following command: $ lessc ./lib/bootstrap.less > bootstrap.css Be sure to include |
Less Mac app |
The unofficial Mac app watches directories of .less files and compiles the code to local files after every save of a watched .less file. If you like, you can toggle preferences in the app for automatic minifying and which directory the compiled files end up in. |