On top of the scaffolding, basic HTML elements are styled and enhanced with extensible classes to provide a fresh, consistent look and feel.
All HTML headings, <h1>
through <h6>
are available.
Bootstrap's global default font-size
is 13px, with a line-height
of 18px. This is applied to the <body>
and all paragraphs. In addition, <p>
(paragraphs) receive a bottom margin of half their line-height (9px 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
.
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: @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 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, <strong>
and <em>
.
<strong>
For emphasizing a snippet of text with important
The following snippet of text is rendered as bold text.
<strong>rendered as bold text</strong>
<em>
For emphasizing a snippet of text with stress
The following snippet of text is rendered as italicized text.
<em>rendered as italicized text</em>
Heads up! 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.
Stylized implemenation of HTML's <abbr>
element for abbreviations and acronyms to show the expanded version on hover. Abbreviations with a title
attribute have a light dotted bottom border and a help cursor on hover, providing additional context on hover.
<abbr>
For expanded text on long hover of an abbreviation, include the title
attribute.
An abbreviation of the word attribute is attr.
<abbr title="attribute">attr</abbr>
<abbr class="initialism">
Add .initialism
to an abbreviation for a slightly smaller font-size.
HTML is the best thing since sliced bread.
<abbr title="attribute" class="initialism">attr</abbr>
Present contact information for the nearest ancestor or the entire body of work.
<address>
Preserve formatting by ending all lines with <br>
.
<address> <strong>Twitter, Inc.</strong><br> 795 Folsom Ave, Suite 600<br> San Francisco, CA 94107<br> <abbr title="Phone">P:</abbr> (123) 456-7890 </address> <address> <strong>Full Name</strong><br> <a href="mailto:#">first.last@gmail.com</a> </address>
For quoting blocks of content from another source within your document.
Wrap <blockquote>
around any HTML as the quote. For straight quotes we recommend a <p>
.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
<blockquote> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p> </blockquote>
Style and content changes for simple variations on a standard blockquote.
Add <small>
tag for identifying the source. Wrap the name of the source work in <cite>
.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
Someone famous in Source Title
<blockquote> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p> <small>Someone famous <cite title="Source Title">Source Title</cite></small> </blockquote>
Use .pull-left
and .pull-right
classes for floated, right-aligned blockquote content.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
Someone famous in Source Title
<blockquote class="pull-right"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p> <small>Someone famous <cite title="Source Title">Source Title</cite></small> </blockquote>
A list of items in which the order does not explicitly matter.
<ul> <li>...</li> </ul>
A list of items in which the order does explicitly matter.
<ol> <li>...</li> </ol>
A list of items with no list-style
or additional left padding.
<ul class="unstyled"> <li>...</li> </ul>
A list of terms with their associated descriptions.
<dl> <dt>...</dt> <dd>...</dd> </dl>
Make terms and descriptions in <dl>
line up side-by-side.
<dl class="dl-horizontal"> <dt>...</dt> <dd>...</dd> </dl>
Heads up!
Horizontal description lists will truncate terms that are too long to fit in the left column fix text-overflow
. In narrower viewports, they will change to the default stacked layout.
Wrap inline snippets of code with <code>
.
For example, <code>section</code> should be wrapped as inline.
Use <pre>
for multiple lines of code. Be sure to escape any angle brackets in the code for proper rendering.
<p>Sample text here...</p>
<pre> <p>Sample text here...</p> </pre>
Note: Be sure to keep code within <pre>
tags as close to the left as possible; it will render all tabs.
You may optionally add the .pre-scrollable
class which will set a max-height of 350px and provide a y-axis scrollbar.
Take the same <pre>
element and add two optional classes for enhanced rendering.
<p>Sample text here...</p>
<pre class="prettyprint linenums"> <p>Sample text here...</p> </pre>
Download google-code-prettify and view the readme for how to use.
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>
Name | Class | Description |
---|---|---|
Default | None | No styles, just columns and rows |
Basic |
.table
|
Only horizontal lines between rows |
Bordered |
.table-bordered
|
Rounds corners and adds outer border |
Zebra-stripe |
.table-striped
|
Adds light gray background color to odd rows (1, 3, 5, etc) |
Condensed |
.table-condensed
|
Cuts vertical padding in half, from 8px to 4px, within all td and th elements |
Tables are automatically styled with only a few borders to ensure readability and maintain structure. With 2.0, the .table
class is required.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
<table class="table"> … </table>
Get a little fancy with your tables by adding zebra-striping—just add the .table-striped
class.
Note: Striped tables use the :nth-child
CSS selector and is not available in IE7-IE8.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
<table class="table table-striped"> … </table>
Add borders around the entire table and rounded corners for aesthetic purposes.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
Mark | Otto | @TwBootstrap | |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
<table class="table table-bordered"> … </table>
Make your tables more compact by adding the .table-condensed
class to cut table cell padding in half (from 8px to 4px).
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
<table class="table table-condensed"> … </table>
Feel free to combine any of the table classes to achieve different looks by utilizing any of the available classes.
Full name | |||
---|---|---|---|
# | First Name | Last Name | Username |
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
<table class="table table-striped table-bordered table-condensed"> ... </table>
Forms include styles for all the base form controls like input
, textarea
, and select
you'd expect. There are also a number of custom components like appended and prepended inputs and support for lists of checkboxes.
Bootstrap provides simple markup and styles for four styles of common web forms. Each layout requires small changes to surrounding markup, but the controls themselves remain and behave the same.
Error, warning, and success states are included for form controls, as wel as disabled.
Name | Class | Description |
---|---|---|
Vertical (default) | .form-vertical (not required) |
Stacked, left-aligned labels over controls |
Inline | .form-inline |
Left-aligned label and inline-block controls for compact style |
Search | .form-search |
Extra-rounded text input for a typical search aesthetic |
Horizontal | .form-horizontal |
Float left, right-aligned labels on same line as controls |
Smart and lightweight defaults without extra markup.
<form class="well"> <label>Label name</label> <input type="text" class="span3" placeholder="Type something…"> <span class="help-block">Example block-level help text here.</span> <label class="checkbox"> <input type="checkbox"> Check me out </label> <button type="submit" class="btn">Submit</button> </form>
Add .form-search
to the form and .search-query
to the input
.
<form class="well form-search"> <input type="text" class="input-medium search-query"> <button type="submit" class="btn">Search</button> </form>
Add .form-inline
to finesse the vertical alignment and spacing of form controls.
<form class="well form-inline"> <input type="text" class="input-small" placeholder="Email"> <input type="password" class="input-small" placeholder="Password"> <label class="checkbox"> <input type="checkbox"> Remember me </label> <button type="submit" class="btn">Sign in</button> </form>
Shown on the right are all the default form controls we support. Here's the bulleted list:
Given the above example form layout, here's the markup associated with the first input and control group. The .control-group
, .control-label
, and .controls
classes are all required for styling.
<form class="form-horizontal"> <fieldset> <legend>Legend text</legend> <div class="control-group"> <label class="control-label" for="input01">Text input</label> <div class="controls"> <input type="text" class="input-xlarge" id="input01"> <p class="help-block">Supporting help text</p> </div> </div> </fieldset> </form>
Bootstrap features styles for browser-supported focused and disabled
states. We remove the default Webkit outline
and apply a box-shadow
in its place for :focus
.
It also includes validation styles for errors, warnings, and success. To use, add the error class to the surrounding .control-group
.
<fieldset class="control-group error"> … </fieldset>
Input groups—with appended or prepended text—provide an easy way to give more context for your inputs. Great examples include the @ sign for Twitter usernames or $ for finances.
Up to v1.4, Bootstrap required extra markup around checkboxes and radios to stack them. Now, it's a simple matter of repeating the <label class="checkbox">
that wraps the <input type="checkbox">
.
Inline checkboxes and radios are also supported. Just add .inline
to any .checkbox
or .radio
and you're done.
To use prepend or append inputs in an inline form, be sure to place the .add-on
and input
on the same line, without spaces.
To add help text for your form inputs, include inline help text with <span class="help-inline">
or a help text block with <p class="help-block">
after the input element.
Instead of making every icon an extra request, we've compiled them into a sprite—a bunch of images in one file that uses CSS to position the images with background-position
. This is the same method we use on Twitter.com and it has worked well for us.
All icons classes are prefixed with .icon-
for proper namespacing and scoping, much like our other components. This will help avoid conflicts with other tools.
Glyphicons has granted us use of the Halflings set in our open-source toolkit so long as we provide a link and credit here in the docs. Please consider doing the same in your projects.
Bootstrap uses an <i>
tag for all icons, but they have no case class—only a shared prefix. To use, place the following code just about anywhere:
<i class="icon-search"></i>
There are also styles available for inverted (white) icons, made ready with one extra class:
<i class="icon-search icon-white"></i>
There are 140 classes to choose from for your icons. Just add an <i>
tag with the right classes and you're set. You can find the full list in sprites.less or right here in this document.
Heads up!
When using beside strings of text, as in buttons or nav links, be sure to leave a space after the <i>
tag for proper spacing.
Icons are great, but where would one use them? Here are a few ideas:
Essentially, anywhere you can put an <i>
tag, you can put an icon.
Use them in buttons, button groups for a toolbar, navigation, or prepended form inputs.