content
Overview of the project, its contents, and how to get started with a simple template.
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>
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">
Bootstrap sets basic global display, typography, and link styles. Specifically, we:
background-color: #fff
; on the body@font-family-base
, @font-size-base
, and
@line-height-base
attributes as our typographic base@link-color
and apply link underlines
only on :hoverThese styles can be found within scaffolding.less
.
For improved cross-browser rendering, we use Normalize.css, a project by Nicolas Gallagher and Jonathan Neal.
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 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:
.container
(fixed-width) or .container-fluid
(full-width) for proper alignment and padding..row
and .col-xs-4
are available for quickly
making grid layouts. Less mixins can also be used for more semantic layouts..row
s..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.
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) { ... }
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.
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
.
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.
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
Easily change the order of our built-in grid columns with .col-md-push-* and .col-md-pull-* modifier classes.
.. column:: .col-md-9 . col-push-3 :width: 9 :push: 3 .. column:: .col-md-3 . col-pull-9 :width: 3 :pull: 9
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` ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
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.
...
Make a paragraph stand out by adding lead.
.. lead:: Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus.
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.
Make use of HTML's default emphasis tags with lightweight styles.
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.
:small:`This line of text is meant to be treated as fine print.`
For emphasizing a snippet of text with a heavier font-weight.
The following snippet of text is **rendered as bold text**.
For emphasizing a snippet of text with italics.
The following snippet of text is *rendered as italicized text*.
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.
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.
A list of items in which the order does not explicitly matter.
* Lorem ipsum dolor sit amet * Consectetur adipiscing elit ...
A list of items in which the order does matter.
1. Lorem ipsum dolor sit amet #. Consectetur adipiscing elit ...
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.
.. class:: list-unstyled * Lorem ipsum dolor sit amet * Consectetur adipiscing elit ...
.. class:: list-inline * Lorem ipsum * Phasellus iaculis * Nulla volutpat
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.
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.
.. 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.
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.
Wrap inline snippets of code with :code:
.
<section>
should be wrapped as inline.For example, :code:`<section>` should be wrapped as inline.
Use the :kbd:
to indicate input that is typically entered via keyboard.
To switch directories, type :kbd:`cd` followed by the name of the directory.
Use .. code::
for multiple lines of code. Be sure to escape any angle brackets in
the code for proper rendering.
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.
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 |
= ========== ========= ======== # First Name Last Name Username = ========== ========= ======== 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter = ========== ========= ========
Use table-striped
to add zebra-striping to any table row within the <tbody>
.
: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 |
.. class:: table-striped = ========== ========= ======== # First Name Last Name Username = ========== ========= ======== 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter = ========== ========= ========
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 |
.. class:: table-bordered table-striped = ========== ========= ======== # First Name Last Name Username = ========== ========= ======== 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter = ========== ========= ========
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 |
.. class:: table-hover = ========== ========= ======== # First Name Last Name Username = ========== ========= ======== 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter = ========== ========= ========
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 |
.. class:: table-condensed = ========== ========= ======== # First Name Last Name Username = ========== ========= ======== 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter = ========== ========= ========
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
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 = ============= ============= ============= ============= =============
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
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
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
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 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
Add classes to an <img>
element to easily style images in any project.
.. image:: 140x140.png :class: img-rounded .. image:: 140x140.png :class: img-circle .. image:: 140x140.png :class: img-thumbnail
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.
: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.`
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.
: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.`