Meta name= viewport content= width=device-width initial-scale=1 la gi
Get the lowdown on the key pieces of Bootstrap's infrastructure, including our approach to better, faster, stronger web development. Show
HTML5 doctypeBootstrap 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.
Mobile firstWith 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
You can disable
zooming capabilities on mobile devices by adding
Typography and linksBootstrap sets basic global display, typography, and link styles. Specifically, we:
These styles can be found within Normalize.cssFor improved cross-browser rendering, we use Normalize.css, a project by Nicolas Gallagher and Jonathan Neal. ContainersBootstrap requires a containing element to wrap site contents and house our grid system. You may choose one of two containers to use in your projects. Note that, due to Use
Use
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. IntroductionGrid 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:
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.
We occasionally expand on these media queries to include a
Grid optionsSee how aspects of the Bootstrap grid system work across multiple devices with a handy table.
Example: Stacked-to-horizontalUsing a single set of .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-4 .col-md-4 .col-md-4
Example: Fluid containerTurn any fixed-width grid layout into a full-width layout by changing your outermost
Example: Mobile and desktopDon't want your columns to simply stack in smaller devices? Use the extra small and medium
device grid classes by adding .col-xs-12 .col-md-8 .col-xs-6 .col-md-4 .col-xs-6 .col-md-4 .col-xs-6 .col-md-4 .col-xs-6 .col-md-4
Example: Mobile, tablet, desktopBuild on the previous example by creating even more dynamic and powerful layouts with tablet .col-xs-12 .col-sm-6 .col-md-8 .col-xs-6 .col-md-4 .col-xs-6 .col-sm-4 .col-xs-6 .col-sm-4 .col-xs-6 .col-sm-4
Example: Column wrappingIf more than 12 columns are placed within a single row, each group of extra columns will, as one unit, wrap onto a new line. .col-xs-9 .col-xs-4 .col-xs-6
Responsive column resetsWith the four tiers of grids available you're bound to run into issues where, at certain breakpoints, your columns don't clear quite right as one is taller than the other. To fix that, use a combination of a .col-xs-6 .col-sm-3 .col-xs-6 .col-sm-3 .col-xs-6 .col-sm-3 .col-xs-6 .col-sm-3
In addition to column clearing at responsive breakpoints, you may need to reset offsets, pushes, or pulls. See this in action in the grid example.
Remove guttersRemove the gutters from a row and it's columns with the .col-xs-12 .col-md-8 .col-xs-6 .col-md-4 .col-xs-6 .col-md-4 .col-xs-6 .col-md-4 .col-xs-6 .col-md-4
Offsetting columnsMove columns to the
right using .col-md-4 .col-md-4 .col-md-offset-4 .col-md-3 .col-md-offset-3 .col-md-3 .col-md-offset-3 .col-md-6 .col-md-offset-3
You can also override offsets from lower grid tiers with
Nesting columnsTo nest your content with the default grid, add a new Level 1: .col-sm-9 Level 2: .col-xs-8 .col-sm-6 Level 2: .col-xs-4 .col-sm-6
Column orderingEasily change the order
of our built-in grid columns with .col-md-9 .col-md-push-3 .col-md-3 .col-md-pull-9
Less mixins and variablesIn addition to prebuilt grid classes for fast layouts, Bootstrap includes Less variables and mixins for quickly generating your own simple, semantic layouts. VariablesVariables determine the number of columns, the gutter width, and the media query point at which to begin floating columns. We use these to generate the predefined grid classes documented above, as well as for the custom mixins listed below.
MixinsMixins are used in conjunction with the grid variables to generate semantic CSS for individual grid columns.
Example usageYou can modify the variables to your own custom values, or just use the mixins with their default values. Here's an example of using the default settings to create a two-column layout with a gap between.
HeadingsAll HTML headings,
Create lighter, secondary text in any heading with a generic
Body copyBootstrap's global 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 copyMake a paragraph stand out by adding Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus.
Built with LessThe typographic scale is based on two Less variables in variables.less: Inline text elementsMarked textFor highlighting a run of text due to its relevance in another context, use the You can use the mark tag to highlight text.
Deleted textFor indicating blocks of text that have been deleted use the This line of text is meant to be treated as deleted text.
Strikethrough textFor indicating blocks of text that are no longer relevant use the This line of text is meant to be treated as no longer accurate.
Inserted textFor indicating additions to the document use the This line of text is meant to be treated as an addition to the document.
Underlined textTo underline text use the This line of text will render as underlined
Make use of HTML's default emphasis tags with lightweight styles. Small textFor de-emphasizing inline or blocks of text, use the You may alternatively use an inline element with This line of text is meant to be treated as fine print.
BoldFor emphasizing a snippet of text with a heavier font-weight. The following snippet of text is rendered as bold text.
ItalicsFor emphasizing a snippet of text with italics. The following snippet of text is rendered as italicized text.
Alternate elementsFeel free to use Alignment classesEasily realign text to components with text alignment classes. Left aligned text. Center aligned text. Right aligned text. Justified text. No wrap text.
Transformation classesTransform text in components with text capitalization classes. Lowercased text. Uppercased text. Capitalized text.
AbbreviationsStylized
implementation of HTML's Basic abbreviationAn abbreviation of the word attribute is attr.
InitialismAdd HTML is the best thing since sliced bread.
AddressesPresent contact information for the nearest ancestor or the entire body of work. Preserve formatting by ending all lines with 1355 Market Street, Suite 900 San Francisco, CA 94103 P: (123) 456-7890 Full Name
BlockquotesFor quoting blocks of content from another source within your document. Default blockquoteWrap
Blockquote optionsStyle and content changes for simple variations on a standard Naming a sourceAdd a
Alternate displaysAdd
ListsUnorderedA list of items in which the order does not explicitly matter.
OrderedA list of items in which the order does explicitly matter.
UnstyledRemove the default
InlinePlace all list items on a single line with
DescriptionA list of terms with their associated descriptions. Description listsA description list is perfect for defining terms.EuismodVestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.Donec id elit non mi porta gravida at eget metus.Malesuada portaEtiam porta sem malesuada magna mollis euismod.
Horizontal descriptionMake terms and descriptions in
Description listsA description list is perfect for defining terms.EuismodVestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.Donec id elit non mi porta gravida at eget metus.Malesuada portaEtiam porta sem malesuada magna mollis euismod. Felis euismod semper eget laciniaFusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
Auto-truncatingHorizontal description lists will truncate terms that are too long to fit in the left column with InlineWrap
inline snippets of code with For example,
User inputUse the To switch directories, type cd followed by the name of the directory.
Basic blockUse
You may optionally add the VariablesFor indicating variables use the y = mx + b
Sample outputFor
indicating blocks sample output from a program use the This text is meant to be treated as sample output from a computer program.
Basic exampleFor basic styling—light padding and only horizontal dividers—add the base class
Optional table caption. Use Striped tables are styled via the
Add
Add
Add
Use contextual classes to color table rows or individual cells.
Using color to add meaning to a table row or individual cell only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (the visible text in the relevant table row/cell), or is included
through alternative means, such as additional text hidden with the Create responsive tables by wrapping any Responsive tables make use of Firefox has some awkward fieldset styling involving For
more information, read this Stack Overflow answer.
Individual form controls automatically receive some global styling. All textual class="help-block">Example block-level help text here. Do not mix form groups directly with input groups. Instead, nest the input group inside of the form group. Add Inputs and selects
have Screen readers will have trouble with your forms if you don't include a label for every input. For these inline forms, you can hide the labels using the Use Bootstrap's predefined grid classes to align labels and groups of form
controls in a horizontal layout by adding Examples of standard form controls supported in an example form layout. Most common form control, text-based input fields. Includes support for all HTML5 types: Inputs will only be fully styled if their Form control which supports multiple lines of text. Change Checkboxes are for selecting one or several options in
a list, while radios are for selecting one option from many. Disabled checkboxes and radios are supported, but to provide a "not-allowed" cursor on hover of the parent Use the Should you have no text within the Note that many native select menus—namely in Safari and Chrome—have rounded corners that cannot be modified via For When you need to place plain text next to a form label within a form, use the We remove the default The above example input uses custom styles in our documentation to demonstrate the Add the Add the
By default, browsers will treat all native form controls ( While Bootstrap will apply these styles in all browsers, Internet Explorer 11 and below don't fully support the Add the Block level help text for form controls. Help text should be explicitly associated with the form control it relates to using the Bootstrap includes validation styles for error, warning, and success states on form controls. To use, add Using these validation styles to denote the state of a form control only provides a visual, color-based indication, which will not be conveyed to users of assistive technologies - such as screen readers - or to colorblind users. Ensure that an alternative indication of state is also provided. For instance, you can include a hint about state in the form control's You can also add optional feedback icons with the addition of Feedback icons only work with textual Manual positioning of feedback icons is required for inputs without a label and for
input groups with an add-on on the right. You are strongly encouraged to provide labels for all inputs for accessibility reasons. If you wish to prevent labels from being displayed, hide them with the To ensure that assistive technologies – such as screen readers – correctly convey the meaning of an icon, additional hidden text should be included with the Although the following examples already mention the validation state of their respective form controls in the Input group with success @ (success) If you use the Hidden label (success) Input group with success @ (success) Set heights using classes like
Create taller or shorter form controls that match button sizes. Quickly size labels and form controls within Wrap inputs in grid columns, or any custom parent element, to easily enforce desired widths. Use the button classes on an While button classes can be used on If the As a best practice, we highly recommend using the Among other things, there's a bug in Firefox <30
that prevents us from setting the Use any of the available button classes to quickly create a styled button. Using color to add meaning to a button only provides a visual indication, which will not be conveyed to
users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (the visible text of the button), or is included through alternative means, such as additional text hidden with the Fancy larger or smaller buttons? Add Create block level buttons—those that span the full width
of a parent— by adding Buttons will appear pressed (with a darker background, darker border, and inset shadow) when active. For No need to add Add the Primary link Link Make
buttons look unclickable by fading them back with Add the If you add the Add the Primary link Link We use This class uses Images
in Bootstrap 3 can be made responsive-friendly via the addition of the To center images which use the In Internet Explorer 8-10, SVG images with 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. class="text-muted">... class="text-primary">... class="text-success">... class="text-info">... class="text-warning">... class="text-danger">... Sometimes emphasis classes cannot be applied due to the specificity of another selector. In most cases, a sufficient workaround is to wrap your text in a Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive
technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (the contextual colors are only used to reinforce meaning that is already present in the text/markup), or is included through alternative means, such as additional text hidden with the 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. class="bg-primary">... class="bg-success">... class="bg-info">... class="bg-warning">... class="bg-danger">... Sometimes contextual background classes cannot be applied due to the specificity of another selector. In some cases, a sufficient workaround is to wrap your element's content in a As with contextual colors,
ensure that any meaning conveyed through color is also conveyed in a format that is not purely presentational. Use the generic close icon for dismissing content like modals and alerts. Use carets to indicate dropdown functionality and direction. Note that the default caret will reverse automatically in
dropup menus. Float an element to the left or right with a class. To align components in navbars with utility
classes, use Set an element to Easily clear Force an element to be shown or hidden (including for screen readers) with the use of Furthermore, Hide an element to all devices except screen readers with Utilize the For faster mobile-friendly development, use these utility
classes for showing and hiding content by device via media query. Also included are utility classes for toggling content when printed. Try to use these on a limited basis and avoid creating entirely different versions of the same site. Instead, use them to complement each device's presentation. Use a single or combination of the available classes for toggling content across viewport breakpoints.
As of v3.2.0, the
So, for extra small ( The classes Similar to the regular responsive
classes, use these for toggling content for print.
The class Resize your browser or load on different devices to test the responsive utility classes. Green checkmarks indicate the element is visible in your current viewport. Extra small ✔ Visible on x-small Small ✔ Visible on small Medium ✔ Visible on medium Large ✔ Visible on large Extra small and small ✔ Visible on x-small and small Medium and large ✔ Visible on medium and large Extra small and medium ✔ Visible on x-small and
medium Small and large ✔ Visible on small and large Extra small and large ✔ Visible on x-small and large Small and medium ✔ Visible on small and medium Here, green checkmarks also indicate the element is hidden in your current viewport. Bootstrap's CSS is built on Less, a preprocessor with additional functionality like
variables, mixins, and functions for compiling CSS. Those looking to use the source Less files instead of our compiled CSS files can make use of the numerous variables and mixins we use throughout the framework. Grid variables and mixins are covered within the Grid system section. Bootstrap can be used in at least two ways: with the compiled CSS or with the
source Less files. To compile the Less files, consult the Getting Started section for how to setup your development environment to run the necessary commands. Third party compilation tools may work with Bootstrap, but they are not supported by our core team. Variables are used throughout the entire project as a way to centralize and share commonly used values
like colors, spacing, or font stacks. For a complete breakdown, please see the Customizer. Easily make use of two color schemes: grayscale and semantic. Grayscale colors provide quick access to commonly used shades of black while semantic include various colors assigned to meaningful contextual values. Use any of these color variables as they are or reassign them to more meaningful variables for your project. A handful of variables for quickly customizing key elements of your site's skeleton. Easily style your links with the right color with only one value. Note that the Easily set your typeface, text size, leading, and more with a few quick variables. Bootstrap makes use of these as well to provide easy typographic mixins. Two quick variables for customizing the location and filename of your icons. Components throughout Bootstrap make use of some default variables for setting common values. Here are the most commonly used. Vendor mixins are mixins to help support multiple browsers by including all relevant vendor prefixes in your compiled CSS. Reset your components' box model with a
single mixin. For context, see this helpful article from Mozilla. The mixin is deprecated as of v3.2.0, with the introduction of Autoprefixer. To preserve backwards-compatibility, Bootstrap will continue to use the mixin internally until Bootstrap v4. Today all modern browsers support
the non-prefixed If your target audience is using the latest and greatest browsers and devices, be sure to just use the The mixin is deprecated as of v3.1.0, since Bootstrap doesn't officially support the outdated platforms that don't support the standard property. To preserve backwards-compatibility, Bootstrap will continue to use the mixin internally until Bootstrap v4. Be sure to use Multiple mixins for flexibility. Set all transition information with one, or specify a separate delay and duration as needed. The mixins are deprecated as of v3.2.0, with the introduction of Autoprefixer. To preserve backwards-compatibility, Bootstrap will continue to use the mixins internally until Bootstrap v4. Rotate, scale, translate
(move), or skew any object. The mixins are deprecated as of v3.2.0, with the introduction of Autoprefixer. To preserve backwards-compatibility, Bootstrap will continue to use the mixins internally until Bootstrap v4. A single mixin for using all of CSS3's animation properties in one declaration and other mixins for individual properties. The mixins are deprecated as of
v3.2.0, with the introduction of Autoprefixer. To preserve backwards-compatibility, Bootstrap will continue to use the mixins internally until Bootstrap v4. Set the opacity for all browsers and provide a Provide context for form controls within each field. Generate columns via CSS within a single element. Easily turn any two colors into a background gradient. Get more advanced and set a direction, use three colors, or use a radial gradient. With a single mixin you get all the prefixed syntaxes you'll need. You can also specify the angle of a standard two-color, linear gradient: If you need a barber-stripe
style gradient, that's easy, too. Just specify a single color and we'll overlay a translucent white stripe. Up the ante and use three colors instead. Set the first color, the second color, the second color's color stop (a percentage value like 25%), and the third color with these mixins: Heads up! Should you ever need to remove a gradient, be sure to remove any IE-specific Utility mixins are mixins that combine otherwise unrelated CSS properties to achieve a specific goal or task. Forget adding Quickly center any element within its parent. Requires Specify the dimensions of an object more easily. Easily
configure the resize options for any textarea, or any other element. Defaults to normal browser behavior ( Easily truncate text with an ellipsis with a single mixin. Requires element to be Specify two image paths and the @1x image dimensions, and Bootstrap will provide an @2x
media query. If you have many images to serve, consider writing your retina image CSS manually in a single media query. While Bootstrap is built on Less, it also has an official Sass port. We maintain it in a separate GitHub repository and handle updates with a conversion script. Since the Sass port has a separate repo and
serves a slightly different audience, the contents of the project differ greatly from the main Bootstrap project. This ensures the Sass port is as compatible with as many Sass-based systems as possible.
Visit the Sass port's GitHub repository to see these files in action. For information on how to install and use Bootstrap for Sass, consult the GitHub repository readme. It's the most up to date source and includes information for use with Rails, Compass, and standard Sass
projects. Bootstrap for Sass |