The core typography, form, and table styles of Bootstrap
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 | Usage | Optional |
---|---|---|
<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.
Element | Usage | Optional |
---|---|---|
<blockquote>
|
Block-level element for quoting content from another source |
Add .pull-left and .pull-right classes for floated options
|
<small>
|
Optional element for adding a user-facing citation, typically an author with title of work |
Place the <cite> around the title or name of source
|
To include a blockquote, wrap <blockquote>
around any HTML as the quote. For straight quotes we recommend a <p>
.
Include an optional <small>
element to cite your source and you'll get an em dash —
before it for styling purposes.
<blockquote> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante venenatis.</p> <small>Someone famous</small> </blockquote>
Default blockquotes are styled as such:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante venenatis.
Someone famous in Body of work
To float your blockquote to the right, add class="pull-right"
:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante venenatis.
Someone famous in Body of work
<ul>
<ul class="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>
Name | Class | Description |
---|---|---|
Default | None | Only horizontal lines between rows |
Bordered |
.bordered-table
|
Rounds corners and adds outter border |
Zebra-stripe |
.striped-table
|
Adds light gray background color to odd rows (1, 3, 5, etc) |
Condensed |
.condensed-table
|
Cuts padding in half, from 10px to 5px, within all td and th elements |
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 .striped-table
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="striped-table"> ... </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="striped-table"> ... </table>
Name | Class | Description |
---|---|---|
Vertical (default) | .vertical-form (not required) |
Stacked, left-aligned labels over controls |
Horiztonal | .horizontal-form |
Float left, right-aligned labels on same line as controls |
Inline | .inline-form |
Left-aligned label and inline-block controls for compact style |
Search | .search-form |
Extra-rounded text input for a typical search aesthetic |
With Bootstrap 2, we completely recoded our forms to allow for simple base styles and improved namespacing on labels and controls. To address the many uses of forms, we've included some base styles to help get you started.
Our default form styles are now vertical, not horizontal. This makes it easier to customize bare-bones forms, as well as forms in tricker situations like sign-up, modals, etc. They share the same exact markup; just swap the class.
Name | Preview | Class | Description |
---|---|---|---|
Default | Button | .btn |
Standard gray button with gradient |
Primary | Button | .primary |
Makes button blue for more visual weight to indicate the primary action in a set of buttons |
Info | Button | .info |
Used as an alternate to the default styles |
Success | Button | .success |
Used to indicate a successful or positive action will be taken |
Danger | Button | .danger |
Used to indicate a dangerous or potentially negative action will be taken |
As a convention, buttons should only be used for actions while hyperlinks are to be used for objects. For instance, "Download" should be a button while "recent activity" should be a link.
Button styles can be applied to anything with the .btn
applied. However, typically you’ll want to apply these to only <a>
and <button>
elements.
Note: All buttons must include the .btn
class. Button styles should be applied to <button>
and <a>
elements for consistency.
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.