Bootstrap RST

Overview of the project, its contents, and how to get started with a simple template.

Overview

Get the lowdown on the key pieces of Bootstrap's infrastructure, including our approach to better, faster, stronger web development.

HTML5 doctype

Bootstrap makes use of certain HTML elements and CSS properties that require the use of the HTML5 doctype. Include it at the beginning of all your projects.

<!DOCTYPE html>
<html lang="en">
...
</html>

Mobile first

With Bootstrap 2, we added optional mobile friendly styles for key aspects of the framework. With Bootstrap 3, we've rewritten the project to be mobile friendly from the start. Instead of adding on optional mobile styles, they're baked right into the core. In fact, Bootstrap is mobile first. Mobile first styles can be found throughout the entire library instead of in separate files.

To ensure proper rendering and touch zooming, add the viewport meta tag to your <head>.

<meta name="viewport" content="width=device-width, initial-scale=1">

You can disable zooming capabilities on mobile devices by adding user-scalable=no to the viewport meta tag. This disables zooming, meaning users are only able to scroll, and results in your site feeling a bit more like a native application. Overall, we don't recommend this on every site, so use caution!

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

Normalize.css

For improved cross-browser rendering, we use Normalize.css, a project by Nicolas Gallagher and Jonathan Neal.

Containers

Easily center a page's contents by wrapping its contents in a .container. Containers set width at various media query breakpoints to match our grid system.

Note that, due to padding and fixed widths, containers are not nestable by default.

.. container::

   ...

Grid system

Bootstrap includes a responsive, mobile first fluid grid system that appropriately scales up to 12 columns as the device or viewport size increases. It includes predefined classes for easy layout options, as well as powerful mixins for generating more semantic layouts.

Introduction

Grid systems are used for creating page layouts through a series of rows and columns that house your content. Here's how the Bootstrap grid system works:

  • Rows must be placed within a .container (fixed-width) or .container-fluid (full-width) for proper alignment and padding.
  • Use rows to create horizontal groups of columns.
  • Content should be placed within columns, and only columns may be immediate children of rows.
  • Predefined grid classes like .row and .col-xs-4 are available for quickly making grid layouts. Less mixins can also be used for more semantic layouts.
  • Columns create gutters (gaps between column content) via padding. That padding is offset in rows for the first and last column via negative margin on .row s.
  • Grid columns are created by specifying the number of twelve available columns you wish to span. For example, three equal columns would use three .col-xs-4. Look to the examples for applying these principles to your code.

Look to the examples for applying these principles to your code.

Media queries

We use the following media queries in our Less files to create the key breakpoints in our grid system.

/* Extra small devices (phones, less than 768px) */
/* No media query since this is the default in Bootstrap */

/* Small devices (tablets, 768px and up) */
@media (min-width: @screen-sm-min) { ... }

/* Medium devices (desktops, 992px and up) */
@media (min-width: @screen-md-min) { ... }

/* Large devices (large desktops, 1200px and up) */
@media (min-width: @screen-lg-min) { ... }

We occasionally expand on these media queries to include a max-width to limit CSS to a narrower set of devices.

@media (max-width: @screen-xs-max) { ... }
@media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { ... }
@media (min-width: @screen-md-min) and (max-width: @screen-md-max) { ... }
@media (min-width: @screen-lg-min) { ... }

Grid options

See how aspects of the Bootstrap grid system work across multiple devices with a handy table.

  Extra small devices Phones (<768px) Small devices Tablets (≥768px) Medium devices Desktops (≥992px) Large devices Desktops (≥1200px)
Grid Behavior Horizontal at all times Collapsed to start, horizontal above breakpoints
Container Width None (auto) 750px 970px 1170px
Class Predix col-xs- col-sd- col-md- col-lg-
# Columns 12
Column Width Auto 60px 78px 95px
Gutter width 30px (15px on each side of a column)
Netsable Yes
Offsets Yes
Column Ordering Yes

Grid classes apply to devices with screen widths greater than or equal to the breakpoint sizes, and override grid classes targeted at smaller devices. Therefore, applying any .col-md- class to an element will not only affect its styling on medium devices but also on large devices if a .col-lg- class is not present.

Example: Stacked-to-horizontal

Using a single set of .col-md-* grid classes, you can create a basic grid system that starts out stacked on mobile devices and tablet devices (the extra small to small range) before becoming horizontal on desktop (medium) devices. Place grid columns in any .row.

.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-8
.col-md-4
.col-md-4
.col-md-4
.col-md-4
.col-md-6
.col-md-6

Offsetting columns

Move columns to the right using .col-md-offset-* classes. These classes increase the left margin of a column by * columns. For example, .col-md-offset-4 moves .col-md-4 over four columns.

.col-md-4
.col-md-4
.col-md-3
.col-md-3
.col-md-6

Nesting columns

To nest your content with the default grid, add a new .row and set of .col-md-* columns within an existing .col-md-* column. Nested rows should include a set of columns that add up to 12 or less.

Level 1: .col-md-9

Level 2: .col-md-6
Level 2: .col-md-6

Column ordering

Easily change the order of our built-in grid columns with .col-md-push-* and .col-md-pull-* modifier classes.

.col-md-9 . col-push-3
.col-md-3 . col-pull-9
.. column:: .col-md-9 . col-push-3
   :width: 9
   :push: 3

.. column:: .col-md-3 . col-pull-9
   :width: 3
   :pull: 9

Typography

Headings

All HTML headings, <h1> through <h6>, are available. .h1 through .h6 classes are also available, for when you want to match the font styling of a heading but still want your text to be displayed inline.

h1. Bootstrap heading

Semibold 36 px

h2. Bootstrap heading

Semibold 30 px

h3. Bootstrap heading

Semibold 24 px

h4. Bootstrap heading

Semibold 18 px
h5. Bootstrap heading
Semibold 14 px
h6. Bootstrap heading
Semibold 12 px
h1. Bootstrap heading
=====================

h2. Bootstrap heading
---------------------

h3. Bootstrap heading
+++++++++++++++++++++

h4. Bootstrap heading
~~~~~~~~~~~~~~~~~~~~~

h5. Bootstrap heading
*********************

h6. Bootstrap heading
¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨

Create lighter, secondary text in any heading with a generic small tag.

h1. Bootstrap heading Secondary text

h2. Bootstrap heading Secondary text

h3. Bootstrap heading Secondary text

h4. Bootstrap heading Secondary text

h5. Bootstrap heading Secondary text
h6. Bootstrap heading Secondary text
h1. Bootstrap heading :small:`Secondary text`
=============================================

h2. Bootstrap heading :small:`Secondary text`
---------------------------------------------

h3. Bootstrap heading :small:`Secondary text`
+++++++++++++++++++++++++++++++++++++++++++++

h4. Bootstrap heading :small:`Secondary text`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

h5. Bootstrap heading :small:`Secondary text`
*********************************************

h6. Bootstrap heading :small:`Secondary text`
¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨

Body copy

Bootstrap's global default font-size is 14px, with a line-height of 1.428. This is applied to the <body> and all paragraphs. In addition, <p> (paragraphs) receive a bottom margin of half their computed line-height (10px by default).

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.

Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec ullamcorper nulla non metus auctor fringilla. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec ullamcorper nulla non metus auctor fringilla.

Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.

...

Lead body copy

Make a paragraph stand out by adding lead.

Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus.
.. lead:: Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor
          auctor. Duis mollis, est non commodo luctus.

Built with Less

The typographic scale is based on two Less variables in variables.less: @font-size-base and @line-height-base. The first is the base font-size used throughout and the second is the base line-height. We use those variables and some simple math to create the margins, paddings, and line-heights of all our type and more. Customize them and Bootstrap adapts.

Emphasis

Make use of HTML's default emphasis tags with lightweight styles.

Small text

For de-emphasizing inline or blocks of text, use the small tag to set text at 85% the size of the parent. Heading elements receive their own font-size for nested small elements.

This line of text is meant to be treated as fine print.
:small:`This line of text is meant to be treated as fine print.`

Bold

For emphasizing a snippet of text with a heavier font-weight.

The following snippet of text is rendered as bold text.
The following snippet of text is **rendered as bold text**.

Italics

For emphasizing a snippet of text with italics.

The following snippet of text is rendered as italicized text.
The following snippet of text is *rendered as italicized text*.

Alternate elements

Feel free to use <b> and <i> in HTML5. <b> is meant to highlight words or phrases without conveying additional importance while <i> is mostly for voice, technical terms, etc.

Alignment classes

Easily realign text to components with text alignment classes.

Left aligned text.

Center aligned text.

Right aligned text.

Justified text.

.. class:: text-left

   Left aligned text.

.. class:: text-center

   Center aligned text.

.. class:: text-right

   Right aligned text.

.. class:: text-justify

   Justified text.

Lists

Unordered

A list of items in which the order does not explicitly matter.

  • Lorem ipsum dolor sit amet
  • Consectetur adipiscing elit
  • Integer molestie lorem at massa
  • Facilisis in pretium nisl aliquet
  • Nulla volutpat aliquam velit
    • Phasellus iaculis neque
    • Purus sodales ultricies
    • Vestibulum laoreet porttitor sem
    • Ac tristique libero volutpat at
  • Faucibus porta lacus fringilla vel
  • Aenean sit amet erat nunc
  • Eget porttitor lorem
* Lorem ipsum dolor sit amet
* Consectetur adipiscing elit
  ...

Ordered

A list of items in which the order does matter.

  1. Lorem ipsum dolor sit amet
  2. Consectetur adipiscing elit
  3. Integer molestie lorem at massa
  4. Facilisis in pretium nisl aliquet
  5. Nulla volutpat aliquam velit
  6. Faucibus porta lacus fringilla vel
  7. Aenean sit amet erat nunc
  8. Eget porttitor lorem
1. Lorem ipsum dolor sit amet
#. Consectetur adipiscing elit
   ...

Unstyled

Remove the default list-style and left margin on list items (immediate children only). This only applies to immediate children list items, meaning you will need to add the class for any nested lists as well.

  • Lorem ipsum dolor sit amet
  • Consectetur adipiscing elit
  • Integer molestie lorem at massa
  • Facilisis in pretium nisl aliquet
  • Nulla volutpat aliquam velit
    • Phasellus iaculis neque
    • Purus sodales ultricies
    • Vestibulum laoreet porttitor sem
    • Ac tristique libero volutpat at
  • Faucibus porta lacus fringilla vel
  • Aenean sit amet erat nunc
  • Eget porttitor lorem
.. class:: list-unstyled

   * Lorem ipsum dolor sit amet
   * Consectetur adipiscing elit
     ...

Inline

  • Lorem ipsum
  • Phasellus iaculis
  • Nulla volutpat
.. class:: list-inline

   * Lorem ipsum
   * Phasellus iaculis
   * Nulla volutpat

Description

A list of terms with their associated descriptions.

Description lists
A description list is perfect for defining terms.
Euismod
Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit. Donec id elit non mi porta gravida at eget metus.
Malesuada porta
Etiam porta sem malesuada magna mollis euismod.
Description lists
 A description list is perfect for defining terms.

Euismod
 Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.
 Donec id elit non mi porta gravida at eget metus.

Malesuada porta
 Etiam porta sem malesuada magna mollis euismod.

Horizontal description

Make terms and descriptions in <dl> line up side-by-side. Starts off stacked like default <dl>s, but when the navbar expands, so do these.

Description lists
A description list is perfect for defining terms.
Euismod
Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit. Donec id elit non mi porta gravida at eget metus.
Malesuada porta
Etiam porta sem malesuada magna mollis euismod.
.. class:: dl-horizontal

   Description lists
    A description list is perfect for defining terms.

   Euismod
    Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.
    Donec id elit non mi porta gravida at eget metus.

   Malesuada porta
    Etiam porta sem malesuada magna mollis euismod.

Auto-truncating

Horizontal description lists will truncate terms that are too long to fit in the left column with text-overflow. In narrower viewports, they will change to the default stacked layout.

Code

Inline

Wrap inline snippets of code with :code:.

For example, <section> should be wrapped as inline.
For example, :code:`<section>` should be wrapped as inline.

User input

Use the :kbd: to indicate input that is typically entered via keyboard.

To switch directories, type cd followed by the name of the directory.
To switch directories, type :kbd:`cd` followed by the name of the directory.

Basic block

Use .. code:: for multiple lines of code. Be sure to escape any angle brackets in the code for proper rendering.

Sample text here...
Sample text here...

You may optionally add the pre-scrollable class, which will set a max-height of 350px and provide a y-axis scrollbar.

Tables

Basic example

For basic styling—light padding and only horizontal dividers—add the base class .table to any <table>. It may seem super redundant, but given the widespread use of tables for other plugins like calendars and date pickers, we've opted to isolate our custom table styles.

# First Name Last Name Username
1 Mark Otto @mdo
2 Jacob Thornton @fat
3 Larry the Bird @twitter
= ========== ========= ========
# First Name Last Name Username
= ========== ========= ========
1 Mark       Otto      @mdo
2 Jacob      Thornton  @fat
3 Larry      the Bird  @twitter
= ========== ========= ========

Striped rows

Use table-striped to add zebra-striping to any table row within the <tbody>.

Cross-browser compatibility

Striped tables are styled via the :nth-child CSS selector, which is not available in Internet Explorer 8.
# First Name Last Name Username
1 Mark Otto @mdo
2 Jacob Thornton @fat
3 Larry the Bird @twitter
.. class:: table-striped

   = ========== ========= ========
   # First Name Last Name Username
   = ========== ========= ========
   1 Mark       Otto      @mdo
   2 Jacob      Thornton  @fat
   3 Larry      the Bird  @twitter
   = ========== ========= ========

Bordered table

Add table-bordered for borders on all sides of the table and cells.

# First Name Last Name Username
1 Mark Otto @mdo
2 Jacob Thornton @fat
3 Larry the Bird @twitter
.. class:: table-bordered table-striped

   = ========== ========= ========
   # First Name Last Name Username
   = ========== ========= ========
   1 Mark       Otto      @mdo
   2 Jacob      Thornton  @fat
   3 Larry      the Bird  @twitter
   = ========== ========= ========

Hover rows

Add table-hover to enable a hover state on table rows within a <tbody>.

# First Name Last Name Username
1 Mark Otto @mdo
2 Jacob Thornton @fat
3 Larry the Bird @twitter
.. class:: table-hover

   = ========== ========= ========
   # First Name Last Name Username
   = ========== ========= ========
   1 Mark       Otto      @mdo
   2 Jacob      Thornton  @fat
   3 Larry      the Bird  @twitter
   = ========== ========= ========

Condensed table

Add table-condensed to make tables more compact by cutting cell padding in half.

# First Name Last Name Username
1 Mark Otto @mdo
2 Jacob Thornton @fat
3 Larry the Bird @twitter
.. class:: table-condensed

   = ========== ========= ========
   # First Name Last Name Username
   = ========== ========= ========
   1 Mark       Otto      @mdo
   2 Jacob      Thornton  @fat
   3 Larry      the Bird  @twitter
   = ========== ========= ========

Contextual classes

Use contextual classes to color table rows or individual cells.

# Column heading Column heading Column heading
1 Column content Column content Column content
2 Column heading Column heading Column heading
3 Column content Column content Column content
4 Column heading Column heading Column heading
5 Column content Column content Column content
6 Column heading Column heading Column heading
7 Column content Column content Column content
8 Column heading Column heading Column heading
9 Column content Column content Column content
.. list-table::
   :widths: 10 30 30 30

   * - #
     - Column heading
     - Column heading
     - Column heading

   * .. class:: active

        - 1
        - Column content
        - Column content
        - Column content

Responsive tables

Create responsive tables by wrapping any .table in .table-responsive to make them scroll horizontally up to small devices (under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.

# Table heading Table heading Table heading Table heading Table heading
1 Table cell Table cell Table cell Table cell Table cell
2 Table cell Table cell Table cell Table cell Table cell
3 Table cell Table cell Table cell Table cell Table cell
.. container:: table-responsive

   .. class:: table-bordered table-striped

      = ============= ============= ============= ============= =============
      # Table heading Table heading Table heading Table heading Table heading
      = ============= ============= ============= ============= =============
      1 Table cell    Table cell    Table cell    Table cell    Table cell
      2 Table cell    Table cell    Table cell    Table cell    Table cell
      3 Table cell    Table cell    Table cell    Table cell    Table cell
      = ============= ============= ============= ============= =============

Buttons

Options

Use any of the available button classes to quickly create a styled button.

.. button:: Default
   :class: default

.. button:: Primary
   :class: primary

.. button:: Success
   :class: success

.. button:: Info
   :class: info

.. button:: Warning
   :class: warning

.. button:: Danger
   :class: danger

.. button:: Link
   :class: link

Sizes

Fancy larger or smaller buttons? Add large, small, or tiny for additional sizes.




.. button:: Large button
   :class: primary large

.. button:: Large button
   :class: large

.. button:: Default button
   :class: primary

.. button:: Default button

.. button:: Small button
   :class: primary small

.. button:: Small button
   :class: small

.. button:: Tiny button
   :class: primary tiny

.. button:: Tiny button
   :class: tiny

Create block level buttons—those that span the full width of a parent by adding block.

.. button:: Block level button
   :class: primary large block

.. button:: Block level button
   :class: large block

Active state

Buttons will appear pressed (with a darker background, darker border, and inset shadow) when active.

.. button:: Primary button
   :class: primary large active

.. button:: Button
   :class: large active

Disabled state

Make buttons look unclickable by fading them back 50% using the disabled option.

.. button:: Primary button
   :class: primary large disabled

.. button:: Button
   :class: large disabled

Images

Responsive images

Images in Bootstrap 3 can be made responsive-friendly via the addition of the .img-responsive class. This applies max-width: 100%; and height: auto; to the image so that it scales nicely to the parent element.

.. image:: image.png
   :class: img-responsive

Image shapes

Add classes to an <img> element to easily style images in any project.

Cross-browser compatibility

Keep in mind that Internet Explorer 8 lacks support for rounded corners.
140x140.png 140x140.png 140x140.png
.. image:: 140x140.png
   :class: img-rounded

.. image:: 140x140.png
   :class: img-circle

.. image:: 140x140.png
   :class: img-thumbnail

Helper classes

Contextual colors

Convey meaning through color with a handful of emphasis utility classes. These may also be applied to links and will darken on hover just like our default link styles.

Fusce dapibus, tellus ac cursus commodo, tortor mauris nibh.
Nullam id dolor id nibh ultricies vehicula ut id elit.
Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
Maecenas sed diam eget risus varius blandit sit amet non magna.
Etiam porta sem malesuada magna mollis euismod.
Donec ullamcorper nulla non metus auctor fringilla.
:text-muted:`Fusce dapibus, tellus ac cursus commodo, tortor mauris nibh.`
:text-primary:`Nullam id dolor id nibh ultricies vehicula ut id elit.`
:text-success:`Duis mollis, est non commodo luctus, nisi erat porttitor ligula.`
:text-info:`Maecenas sed diam eget risus varius blandit sit amet non magna.`
:text-warning:`Etiam porta sem malesuada magna mollis euismod.`
:text-danger:`Donec ullamcorper nulla non metus auctor fringilla.`

Contextual background

Similar to the contextual text color classes, easily set the background of an element to any contextual class. Anchor components will darken on hover, just like the text classes.

Nullam id dolor id nibh ultricies vehicula ut id elit.
Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
Maecenas sed diam eget risus varius blandit sit amet non magna.
Etiam porta sem malesuada magna mollis euismod.
Donec ullamcorper nulla non metus auctor fringilla.
:bg-primary:`Nullam id dolor id nibh ultricies vehicula ut id elit.`
:bg-success:`Duis mollis, est non commodo luctus, nisi erat porttitor ligula.`
:bg-info:`Maecenas sed diam eget risus varius blandit sit amet non magna.`
:bg-warning:`Etiam porta sem malesuada magna mollis euismod.`
:bg-danger:`Donec ullamcorper nulla non metus auctor fringilla.`