CSS
Global CSS settings, fundamental HTML elements styled and enhanced with extensible classes, and an advanced grid system.
Global CSS settings, fundamental HTML elements styled and enhanced with extensible classes, and an advanced grid system.
Get the lowdown on the key pieces of Bootstrap's infrastructure, including our approach to better, faster, stronger web development.
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 :hover
These styles can be found within scaffolding.less
.
For improved cross-browser rendering, we use Normalize.css, a project by Nicolas Gallagher and Jonathan Neal.
Bootstrap 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 padding
and more, neither container is nestable.
Use .container
for a responsive fixed width container.
<div class="container">
...
</div>
Use .container-fluid
for a full width container, spanning the entire width of your viewport.
<div class="container-fluid">
...
</div>
Classes to apply to elements contained within block-level elements with a relative display.
The content within a relatively displayed block element can be positioned in the following positions. The content must be wrapped within a div with the appropriate alignment class as shown in the examples below. Please remember that the classes ignore the parent container's padding.
Top Left
Center Left
Bottom Left
Top Center
Center Center
Bottom Center
Top Right
Center Right
Bottom Right
<div class="well no-shadow jumbotron-large">
<div class="align-top-left">
<p>Top Left</p>
</div>
<div class="align-center-left">
<p>Center Left</p>
</div>
<div class="align-bottom-left">
<p>Bottom Left</p>
</div>
<div class="align-top-center">
<p>Top Center</p>
</div>
<div class="align-center-center">
<p>Center Center</p>
</div>
<div class="align-bottom-center">
<p>Bottom Center</p>
</div>
<div class="align-top-right">
<p>Top Right</p>
</div>
<div class="align-center-right">
<p>Center Right</p>
</div>
<div class="align-bottom-right">
<p>Bottom Right</p>
</div>
</div>
To simply align an element vertically, centering it from top to bottom of its container, use the .align-vertical-center
class.
This is centered vertically only.
<div class="well no-shadow jumbotron-large">
<div class="align-vertical-center">
<p>This is centered vertically only.</p>
</div>
</div>
Use the button classes on an <a>
, <button>
, or <input>
element.
<a class="btn btn-default" href="#" role="button">Link</a>
<button class="btn btn-default" type="submit">Button</button>
<input class="btn btn-default" type="button" value="Input">
<input class="btn btn-default" type="submit" value="Submit">
While button classes can be used on <a>
and <button>
elements, only <button>
elements are supported within our nav and navbar components.
If the <a>
elements are used to act as buttons – triggering in-page functionality, rather than navigating to another document or section within the current page – they should also be given an appropriate role="button"
.
As a best practice, we highly recommend using the <button>
element whenever possible to ensure matching cross-browser rendering.
Among other things, there's a bug in Firefox <30 that prevents us from setting the line-height
of <input>
-based buttons, causing them to not exactly match the height of other buttons on Firefox.
Use any of the available button classes to quickly create a styled button.
<button type="button" class="btn btn-default">Default</button>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-ghost">Ghost</button>
<button type="button" class="btn btn-info">Info</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-link">Link</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 .sr-only
class.
By default, Bootstrap ensures that the text within a button does not wrap. The reason has a long history in UX considerations, such as those outlined in UX Movement's rules [Ed.: text case being arbitrary]. The same best practices for naming hyperlinks apply (e.g., no wordy "click here to" or generic "more" labels). With buttons, the rules extend further because their labels should stand out by using active verbs that convey the meaning of the action precisely and succinctly. The button labels are normally echoing wording that is used above them that asks a user a specific question. In the event there is a need to wrap the inner text of a button because its text causes the button to flow outside of its container, apply the btn-wrap-normal
class.
This area is 5/6 of a row's width.
This area is 5/6 of a row's width.
Fancy larger or smaller buttons? Add .btn-lg
, .btn-sm
, or .btn-xs
for additional sizes.
<div>
<button type="button" class="btn btn-primary btn-lg">Large button</button>
</div>
<div>
<button type="button" class="btn btn-primary">Default button</button>
</div>
<div>
<button type="button" class="btn btn-primary btn-sm">Small button</button>
</div>
<div>
<button type="button" class="btn btn-primary btn-xs">Extra small button</button>
</div>
Placing buttons side-by-side can create usability issues in determining where each button begins and ends, especially if all buttons are the same color. Add the following classes to the wrapping tag to add more button to the default side-by-side spacing: .btn-spacing-1
, .btn-spacing-2
, .btn-spacing-3
, or .btn-spacing-4
<div class="btn-spacing-1">
<button type="button" class="btn btn-primary">Spacing is a</button>
<button type="button" class="btn btn-primary">margin of 10px</button>
</div>
<div class="btn-spacing-2">
<button type="button" class="btn btn-primary">Spacing is a</button>
<button type="button" class="btn btn-primary">margin of 20px</button>
</div>
<div class="btn-spacing-3">
<button type="button" class="btn btn-primary">Spacing is a</button>
<button type="button" class="btn btn-primary">margin of 30px</button>
</div>
<div class="btn-spacing-4">
<button type="button" class="btn btn-primary">Spacing is a</button>
<button type="button" class="btn btn-primary">margin of 40px</button>
</div>
Buttons are aligned to the left by default.
You can align buttons to the right by applying .pull-right
.
<button type="button" class="btn btn-primary pull-right">.pull-right Button</button>
If different sections on a page require buttons only relevant to that section, you can create an in-line section heading with buttons by wrapping the buttons in a surrounding div with .button-nav
.
The buttons will align to the right of the screen through the medium breakpoint and then align to the left on small through x-small breakpoints.
<div class="row">
<div class="col-md-6">
<h3 class="margin-top-none">Section Heading</h3>
</div>
<div class="col-md-6">
<div class="button-nav">
<button type="button" class="btn btn-primary">Button 1</button>
<button type="button" class="btn btn-default">Button 2</button>
</div>
</div>
</div>
Create block level buttons—those that span the full width of a parent— by adding .btn-block
. These buttons will always be centered.
<button type="button" class="btn btn-primary btn-block">Block level button</button>
<button type="button" class="btn btn-default btn-block">Block level button</button>
Buttons will appear pressed (with a darker background, darker border, and inset shadow) when active. For <button>
elements, this is done via :active
. For <a>
elements, it's done with .active
. However, you may use .active
on <button>
s (and include the aria-pressed="true"
attribute) should you need to replicate the active state programmatically.
No need to add :active
as it's a pseudo-class, but if you need to force the same appearance, go ahead and add .active
.
<button type="button" class="btn btn-primary btn-lg active">Primary button</button>
<button type="button" class="btn btn-default btn-lg active">Button</button>
Add the .active
class to <a>
buttons.
<a href="#" class="btn btn-primary btn-lg active" role="button">Primary link</a>
<a href="#" class="btn btn-default btn-lg active" role="button">Link</a>
Make buttons look unclickable by fading them back with opacity
.
Add the disabled
attribute to <button>
buttons.
<button type="button" class="btn btn-lg btn-primary" disabled="disabled">Primary button</button>
<button type="button" class="btn btn-default btn-lg" disabled="disabled">Button</button>
<button type="button" class="btn btn-default btn-lg" disabled="disabled"><i class="icon icon-edit" aria-hidden="true"></i> Button with Icon</button>
If you add the disabled
attribute to a <button>
, Internet Explorer 9 and below will render text gray with a nasty text-shadow that we cannot fix.
Add the .disabled
class to <a>
buttons.
<a href="#" class="btn btn-primary btn-lg disabled" role="button">Primary link</a>
<a href="#" class="btn btn-default btn-lg disabled" role="button">Link</a>
We use .disabled
as a utility class here, similar to the common .active
class, so no prefix is required.
This class uses pointer-events: none
to try to disable the link functionality of <a>
s, but that CSS property is not yet standardized and isn't fully supported in Opera 18 and below, or in Internet Explorer 11. In addition, even in browsers that do support pointer-events: none
, keyboard navigation remains unaffected, meaning that sighted keyboard users and users of assistive technologies will still be able to activate these links. So to be safe, use custom JavaScript to disable such links.
Wrap inline snippets of code with <code>
.
<section>
should be wrapped as inline.
For example, <code><section></code> should be wrapped as inline.
Use the <kbd>
to indicate input that is typically entered via keyboard.
To switch directories, type <kbd>cd</kbd> followed by the name of the directory.<br>
To edit settings, press <kbd><kbd>ctrl</kbd> + <kbd>,</kbd></kbd>
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>
You may optionally add the .pre-scrollable
class, which will set a max-height of 350px and provide a y-axis scrollbar.
For indicating variables use the <var>
tag.
y = mx + b
<var>y</var> = <var>m</var><var>x</var> + <var>b</var>
For indicating blocks sample output from a program use the <samp>
tag.
This text is meant to be treated as sample output from a computer program.
<samp>This text is meant to be treated as sample output from a computer program.</samp>
Individual form controls automatically receive some global styling. All textual <input>
, <textarea>
, and <select>
elements with .form-control
are set to width: 100%;
by default. Wrap labels and controls in .form-group
for optimum spacing.
<form>
<div class="form-group required">
<label for="profile-username-1">Username</label>
<input type="text" class="form-control" id="profile-username-1" placeholder="Create username">
</div>
<div class="form-group required">
<label for="create-password-1">Password</label>
<input type="password" class="form-control" id="create-password-1" placeholder="Password">
</div>
<div class="form-group required">
<label for="confirm-password-1">Confirm password</label>
<input type="password" class="form-control" id="confirm-password-1" placeholder="Re-type password">
</div>
<div class="custom-file-group required">
<label for="upload-file">Upload file</label>
<div class="custom-file" id="upload-file">
<input type="file" class="custom-file-input" id="example-file-upload-1">
<label class="custom-file-label" for="example-file-upload-1">Choose file</label>
<div class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</div>
</div>
</div>
<div class="checkbox">
<label>
<input type="checkbox">
<span></span> I agree to the terms
</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
Do not mix form groups directly with input groups. Instead, nest the input group inside of the form group.
Add .form-inline
to your form (which doesn't have to be a <form>
) for left-aligned and inline-block controls. This only applies to forms within viewports that are at least 768px wide.
Inputs and selects have width: 100%;
applied by default in Bootstrap. Within inline forms, we reset that to width: auto;
so multiple controls can reside on the same line. Depending on your layout, additional custom widths may be required.
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 .sr-only
class. There are further alternative methods of providing a label for assistive technologies, such as the aria-label
, aria-labelledby
or title
attribute. If none of these is present, screen readers may resort to using the placeholder
attribute, if present, but note that use of placeholder
as a replacement for other labelling methods is not advised.
<form class="form-inline">
<div class="form-group">
<label for="example-input-name-1">Name</label>
<input type="text" class="form-control" id="example-input-name-1" placeholder="Jane Doe">
</div>
<div class="form-group">
<label for="example-input-email-1">Email</label>
<input type="email" class="form-control" id="example-input-email-1" placeholder="jane.doe@example.com">
</div>
<button type="submit" class="btn btn-default">Send invitation</button>
</form>
<form class="form-inline no-labels">
<div class="form-group">
<label class="sr-only" for="example-input-email-2">Email address</label>
<input type="email" class="form-control" id="example-input-email-2" placeholder="Email">
</div>
<div class="form-group">
<label class="sr-only" for="example-input-password-1">Password</label>
<input type="password" class="form-control" id="example-input-password-1" placeholder="Password">
</div>
<div class="checkbox">
<label>
<input type="checkbox">
<span></span> Remember me
</label>
</div>
<button type="submit" class="btn btn-default">Sign in</button>
</form>
<form class="form-inline no-labels">
<div class="form-group">
<label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
<div class="input-group">
<div class="input-group-addon">$</div>
<input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
<div class="input-group-addon">.00</div>
</div>
</div>
<button type="submit" class="btn btn-primary">Transfer cash</button>
</form>
Use Bootstrap's predefined grid classes to align labels and groups of form controls in a horizontal layout by adding .form-horizontal
to the form (which doesn't have to be a <form>
). Doing so changes .form-group
s to behave as grid rows, so no need for .row
.
<form class="form-horizontal">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword3" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label>
<input type="checkbox">
<span></span> Remember me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Sign in</button>
</div>
</div>
</form>
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: text
, password
, datetime
, datetime-local
, date
, month
, time
, week
, number
, email
, url
, search
, tel
, and color
. Using these input types are especially important for usability on mobile devices and prompting keyboard suggestions.
For inputs that need a calendar for a single date or date range, we have a plug-in that can be used that is styled with our FEF. This date picker does not currently support time (hh:mm). For further documentation around the plug-in: https://bootstrap-datepicker.readthedocs.io/en/stable/index.html
Reference MDN web docs for more examples:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
Inputs will only be fully styled if their type
is properly declared.
<!-- Text -->
<input type="text" class="form-control" id="textOnly" name="textOnlyEx" placeholder="Text input">
<!-- Password -->
<input type="password" class="form-control" id="passwordOnly" name="passwordOnlyEx" placeholder="Password input">
<!-- Month -->
<input type="month" class="form-control" id="month-only" name="month-only-ex" placeholder="">
<!-- Date using our datepicker plug-in -->
<form class="margin-bottom-1">
<label for="date-only">Date Ex:</label>
<div class="input-group date" data-provide="datepicker">
<input type="text" class="form-control" value="mm/dd/yyyy" id="date-only" name="date-only-ex" placeholder="">
<span class="input-group-addon"><span class="icon icon-calendar"></span></span>
</div>
</form>
<!-- Date Range using our datepicker plug-in -->
<form class="margin-bottom-1">
<label for="date-range">Date Range Ex:</label>
<div class="input-group input-daterange" data-provide="datepicker">
<input type="text" class="form-control" value="mm/dd/yyyy" id="date-range-start" name="date-range-start" placeholder="">
<span class="input-group-addon">to</span>
<input type="text" class="form-control" value="mm/dd/yyyy" id="date-range-end" name="date-only-end" placeholder="">
</div>
</form>
<!-- Time -->
<input type="time" class="form-control" id="timeOnly" name="timeOnlyEx" placeholder="">
<!-- Date/Time Local -->
<input type="datetime-local" class="form-control" id="dateTimeLocal" name="dateTimeLocalEx"placeholder="">
<!-- Date/Time Local w/Restrictions -->
<input type="datetime-local" class="form-control" id="dateTimeLocalRestrict" name="dateTimeLocalRestrictEx" value="2018-06-12T19:30" min="2018-06-07T00:00" max="2018-06-14T00:00" placeholder="">
<!-- Week -->
<input type="week" class="form-control" id="week-only" name="week-only-ex" placeholder="">
<!-- Number -->
<input type="number" class="form-control" id="numbers" name="numbersEx" placeholder="">
<!-- Telephone -->
<input type="tel" class="form-control" id="telephone" name="telephoneEx" placeholder="Phone number">
<!-- Email -->
<input type="email" class="form-control" id="email" name="emailEx" placeholder="hello@mailserver.com">
<!-- URL -->
<input type="url" class="form-control" id="url" name="urlEx" placeholder="https://example.com" pattern="https://.*">
<!-- Search -->
<input type="search" class="form-control" id="search" name="searchEx" placeholder="Search for...">
<!-- Color Picker -->
<fieldset>
<legend for="colorEx">Color (Picker) Ex:</legend>
<div>
<input type="color" id="color1" name="colorEx" value="#00ad21">
<label for="color1">Color 1</label>
</div>
<div>
<input type="color" id="color2" name="colorEx" value="#e6e6f0">
<label for="color2">Color 2</label>
</div>
</fieldset>
To add integrated text or buttons before and/or after any text-based <input>
, check out the input group component.
Form control which supports multiple lines of text. Change rows
attribute as necessary.
<textarea class="form-control" rows="3"></textarea>
Checkboxes enable the selection of one or several options in a list, while radio buttons allow the selection of one option from many.
Disabled checkboxes and radio buttons are supported. To provide a "not-allowed" cursor on hover of the parent <label>
, you'll need to add the .disabled
class to the parent .radio
, .radio-inline
, .checkbox
, or .checkbox-inline
.
<form>
<div class="form-group">
<fieldset>
<legend>Select one or more of the options below:</legend>
<div class="checkbox">
<label>
<input type="checkbox" value="">
<span></span> Option one is this and that—be sure to include why it's great
</label>
</div>
<div class="checkbox disabled">
<label>
<input type="checkbox" value="" disabled>
<span></span> Option two is disabled
</label>
</div>
<div class="checkbox disabled">
<label>
<input type="checkbox" value="" disabled checked>
<span></span> Option three is disabled, but checked
</label>
</div>
</fieldset>
</div>
<div class="form-group">
<fieldset>
<legend>Select one of the options below:</legend>
<div class="radio">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
<span></span> Option one is this and that—be sure to include why it's great
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
<span></span> Option two can be something else and selecting it will deselect option one
</label>
</div>
<div class="radio disabled">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios3" value="option3" disabled>
<span></span> Option three is disabled
</label>
</div>
<div class="radio disabled">
<label>
<input type="radio" name="optionsRadiosDISABLED" id="optionsRadios4" value="option4" disabled checked>
<span></span> Option four is disabled, but checked
</label>
</div>
</fieldset>
</div>
</form>
Use the class .form-inline
to modify the form and receive automatic inline styling for checkbox and/or radio button groups.
<form class="form-inline">
<div class="form-group">
<fieldset>
<legend>Select additional accessories:</legend>
<label>
<input type="checkbox" id="inlineCheckbox1" value="option1">
<span></span> Tie
</label>
<label>
<input type="checkbox" id="inlineCheckbox2" value="option2">
<span></span> Belt
</label>
<label>
<input type="checkbox" id="inlineCheckbox3" value="option3">
<span></span> Shoes
</label>
</fieldset>
</div>
<div class="form-group">
<fieldset>
<legend>Schedule a callback:</legend>
<label>
<input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
<span></span> Yes
</label>
<label>
<input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
<span></span> No
</label>
<label>
<input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
<span></span> Maybe
</label>
</fieldset>
</div>
</form>
In a default (stacked) form, use .legend-inline
along with .checkbox-inline
or .radio-inline
classes on a series of checkboxes or radio buttons to make controls appear on the same line.
<form>
<div class="form-group">
<fieldset>
<legend class="legend-inline">Add options:</legend>
<label class="checkbox-inline">
<input type="checkbox" id="customInlineCheckbox1" value="option1">
<span></span> Alloy wheels
</label>
<label class="checkbox-inline">
<input type="checkbox" id="customInlineCheckbox2" value="option2">
<span></span> Sun roof
</label>
<label class="checkbox-inline">
<input type="checkbox" id="customInlineCheckbox3" value="option3">
<span></span> All weather mats
</label>
</fieldset>
</div>
<div class="form-group">
<fieldset>
<legend class="legend-inline">Select exterior color:</legend>
<label class="radio-inline">
<input type="radio" name="customInlineRadioOptions" id="customInlineRadio1" value="option1">
<span></span> Silver
</label>
<label class="radio-inline">
<input type="radio" name="customInlineRadioOptions" id="customInlineRadio2" value="option2">
<span></span> Red
</label>
<label class="radio-inline">
<input type="radio" name="customInlineRadioOptions" id="customInlineRadio3" value="option3">
<span></span> Blue
</label>
</fieldset>
</div>
</form>
In a default (stacked) form, use only the .checkbox-inline
or .radio-inline
classes on a series of checkboxes or radio buttons to make controls appear on the same line. Avoid adding the .legend-inline
style to make the group title appear on the line above it.
<form>
<div class="form-group">
<fieldset>
<legend>Add options:</legend>
<label class="checkbox-inline">
<input type="checkbox" id="customStackingInlineCheckbox1" value="option1">
<span></span> Alloy wheels
</label>
<label class="checkbox-inline">
<input type="checkbox" id="customStackingInlineCheckbox2" value="option2">
<span></span> Sun roof
</label>
<label class="checkbox-inline">
<input type="checkbox" id="customStackingInlineCheckbox3" value="option3">
<span></span> All weather mats
</label>
</fieldset>
</div>
<div class="form-group">
<fieldset>
<legend>Select exterior color:</legend>
<label class="radio-inline">
<input type="radio" name="customStackingInlineRadioOptions" id="customStackingInlineRadio1" value="option1">
<span></span> Silver
</label>
<label class="radio-inline">
<input type="radio" name="customStackingInlineRadioOptions" id="customStackingInlineRadio2" value="option2">
<span></span> Red
</label>
<label class="radio-inline">
<input type="radio" name="customStackingInlineRadioOptions" id="customStackingInlineRadio3" value="option3">
<span></span> Blue
</label>
</fieldset>
</div>
</form>
Without text within the <label>
tag, the input is positioned as expected. This currently only works on non-inline checkboxes and radio buttons. Remember to still provide some form of label for assistive technologies (for instance, using aria-label
).
<div class="checkbox">
<label>
<input type="checkbox" id="blankCheckbox" value="option1" aria-label="...">
<span></span>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="blankRadio" id="blankRadio1" value="option1" aria-label="...">
<span></span>
</label>
</div>
Selects are implemented as dropdowns using the third-party plug-in Bootstrap-Select. For more information on accessibility on select menus, see WebAIM's Creating Accessible Forms
When no option has the selected
attribute, the default option shown within the select menu will be the first enabled option within the list.
When a label tag is present the messaging to further describe the purpose of the select menu to the user - as a disabled option - is optional, but the aria-label is still recommended.
<label for="results-per-page">Results per page</label>
<select id="results-per-page" name="results-per-page" class="form-control" aria-label="Choose results per page">
<option disabled>Choose results per page</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
When no option has the selected
attribute, the default option shown within the select menu will be the first enabled option within the list.
When the select form does not include a label tag:
aria-label
attribute should be included within the select tag.<select id="favorite-color" name="favorite-color" class="form-control" aria-label="Choose favorite color">
<option disabled selected>Choose favorite color</option>
<option value="1">Red</option>
<option value="2">Blue</option>
<option value="3">Green</option>
<option value="4">Yellow</option>
<option value="5">Purple</option>
</select>
Add the multiple
attribute to allow selecting more than one option.
You should replace the aria-label
with the title
attribute to show the title within the select field and to further describe the purpose of the select menu to the user.
<select id="favorite-letters" name="favorite-letters" title="Favorite letters" class="form-control" multiple>
<option disabled>Select favorite letters</option>
<option value="1">Alpha</option>
<option value="2">Bravo</option>
<option value="3">Charlie</option>
<option value="4">Delta</option>
<option value="5">Echo</option>
<option value="6">Foxtrot</option>
<option value="7">Golf</option>
<option value="8">Hotel</option>
<option value="9">India</option>
<option value="10">Juliet</option>
</select>
Add the multiple
attribute to allow selecting more than one option.
You should replace the aria-label
with the title
attribute to show the title within the select field and to further describe the purpose of the select menu to the user.
Add the data-multiple-separator="<br>"
to display each selected option as a new line item within the select field.
<select id="favorite-letters-heights" name="favorite-letters-heights" title="Favorite letters" class="form-control" multiple data-multiple-separator="<br>">
<option disabled>Select favorite letters</option>
<option value="1">Alpha</option>
<option value="2">Bravo</option>
<option value="3">Charlie</option>
<option value="4">Delta</option>
<option value="5">Echo</option>
<option value="6">Foxtrot</option>
<option value="7">Golf</option>
<option value="8">Hotel</option>
<option value="9">India</option>
<option value="10">Juliet</option>
</select>
We use a customized version of Bootstrap 4's bs-custom-file-input in order to provide textual feedback in the label.
The file input requires additional JavaScript to hook it up with the functional Choose file… and selected file name text. Be sure to match the 'id' and 'for' values of the input and label tags.
When the user touches the input box or button, a file upload window specific to the user's OS will appear. Once the user selects a file, its filename will be shown in the input text box. If more than one file is selected, a phrase indicating the number of files selected will appear. Additional feedback may be placed in the "help-block" section as needed.
<div class="custom-file-group">
<div class="custom-file custom-file-button-only">
<input type="file" class="custom-file-input" id="default-file-selection-button">
<label class="custom-file-label" for="default-file-selection-button">Choose file</label>
<div class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="custom-file-group custom-file-lg">
<label for="single-file-large">Large</label>
<div class="custom-file" id="single-file-large">
<input type="file" class="custom-file-input" id="custom-file-single-lg">
<label class="custom-file-label" for="custom-file-single-lg">Choose file</label>
<div class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</div>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="custom-file-group">
<label for="single-file-default">Default</label>
<div class="custom-file" id="single-file-default">
<input type="file" class="custom-file-input" id="custom-file-single">
<label class="custom-file-label" for="custom-file-single">Choose file</label>
<div class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</div>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="custom-file-group custom-file-sm">
<label for="single-file-small">Small</label>
<div class="custom-file" id="single-file-small">
<input type="file" class="custom-file-input" id="custom-file-single-sm">
<label class="custom-file-label" for="custom-file-single-sm">Choose file</label>
<div class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</div>
</div>
</div>
</div>
</div>
Add the class .required
to the .custom-file-group
container.
<div class="row">
<div class="col-lg-12">
<div class="custom-file-group">
<label for="single-file-default">Default</label>
<div class="custom-file" id="single-file-default">
<input type="file" class="custom-file-input" id="custom-file-single">
<label class="custom-file-label" for="custom-file-single">Choose file</label>
<div class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</div>
</div>
</div>
</div>
</div>
<div class="custom-file-group">
<div class="custom-file">
<input type="file" class="custom-file-input" id="custom-file-multiple" multiple>
<label class="custom-file-label" for="custom-file-multiple">Choose file(s)</label>
<div class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</div>
</div>
</div>
<div class="custom-file-group">
<div class="custom-file">
<input type="file" class="custom-file-input" id="custom-file-disabled" disabled>
<label class="custom-file-label" for="custom-file-disabled">Choose file</label>
<div class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</div>
</div>
</div>
We hide the default file <input>
via opacity
and instead style the <label>
. The button is generated and positioned with ::after
. Lastly, we declare a width
and height
on the <input>
for proper spacing for surrounding content.
The :lang() pseudo-class is used to allow for translation of the “Browse” text into other languages. Override or add entries to the $custom-file-text
Sass variable with the relevant language tag and localized strings. You may find these in the /src/sass/modules/_custom-file-input.scss
file. The English strings may be customized the same way.
lang
Attribute Required for LocalizationThe lang attribute must be applied to a parent tag for the button and feedback translations to take effect. This will work if the attribute is applied to the html
tag or on a container element as shown in the examples further below.
$custom-file-text: (
en: "Browse", // english
bg: "избирам", // bulgarian
cs: "Vybrat", // czech
da: "Vælge", // danish
de: "Wählen", // german
el: "Επιλέγω", // greek
es: "Elegir", // spanish
fi: "Valita", // finnish
fr: "Choisir", // french
he: "בחר", // hebrew
hr: "izabrati", // croatian
hu: "Választ", // hungarian
it: "Scegliere", // italian
ja: "選ぶ", // japanese
ko: "고르다", // korean
nl: "Kiezen", // dutch
no: "Velge", // norwegian
pl: "Wybierać", // polish
pt: "Escolher", // portuguese
ro: "Alege", // romanian
ru: "выбирать", // russian
sk: "zvoliť", // slovak
sr: "Изаберите", // serbian
sv: "Välja", // swedish
tr: "Seç", // turkish
zh: "選擇" // chinese
) !default;
Additionally, for multiple file selection, we have customized the JavaScript plug-in as bs-custom-file-input-custom.js to provide localized feedback.
The #
in the phrases below are replaced with the total number of file selected. If none are present, the total number is placed at the beginning of the phrase.
singular: {
en: 'file selected',
bg: 'Избран е # файл',
cs: 'Byl vybrán # soubor',
da: 'fil valgt',
de: 'Datei ausgewählt',
el: 'Επιλέχθηκε # αρχείο',
es: 'archivo seleccionado',
fi: 'tiedosto valittu',
fr: 'fichier sélectionné',
he: 'נבחר קובץ #',
hr: 'Odabrana je # datoteka',
hu: 'fájl kiválasztva',
it: 'file selezionato',
ja: '#ファイルを選択',
ko: '# 개 파일 선택',
nl: 'bestand geselecteerd',
no: 'fil valgt',
pl: 'Wybrano # plik',
pt: 'arquivo selecionado',
ro: 'fișier selectat',
ru: 'Выбран # файл',
sk: 'Je vybratý # súbor',
sr: 'Изабрана је # датотека',
sv: 'fil vald',
tr: 'dosya seçildi',
zh: '已選擇#個文件'
},
plural: {
en: 'files selected',
bg: 'Избрани са # файла',
cs: 'vybrané soubory',
da: 'valgte filer',
de: 'Dateien ausgewählt',
el: 'Επιλέχθηκαν # αρχεία',
es: 'archivos seleccionados',
fi: 'tiedostoa valittu',
fr: 'fichiers sélectionnés',
he: '# קבצים שנבחרו',
hr: 'Odabrane su # datoteke',
hu: 'fájl kiválasztva',
it: 'file selezionati',
ja: '#ファイルを選択',
ko: '# 개 파일 선택',
nl: 'bestanden geselecteerd',
no: 'filer valgt',
pl: 'Wybrano # pliki',
pt: 'arquivos selecionados',
ro: 'fișiere selectate',
ru: 'Выбрано # файла',
sk: 'Vybraté sú # súbory',
sr: 'Изабране су # датотеке',
sv: 'filer valda',
tr: 'dosya seçildi',
zh: '已選擇#個文件'
}
The label
text used for the placeholder text in the faux input box and the help-block
text is custom; therefore, it will need to be translated and added manually.
<div class="row">
<div class="col-lg-12">
<div class="custom-file-group">
<label for="multiple-file-zh">Chinese File Browser</label>
<div class="custom-file" id="multiple-file-zh" lang="zh">
<input type="file" class="custom-file-input" id="custom-file-lang-zh" multiple>
<label class="custom-file-label" for="custom-file-lang-zh">選擇文件</label>
<div class="help-block">一段幫助文本,可以換行,並且可以延伸到一行之外。</div>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="custom-file-group">
<label for="multiple-file-fr">French File Browser</label>
<div class="custom-file" id="multiple-file-fr" lang="fr">
<input type="file" class="custom-file-input" id="custom-file-lang-fr" multiple>
<label class="custom-file-label" for="custom-file-lang-fr">Choisir les fichiers</label>
<div class="help-block">Un bloc de texte d'aide qui saute sur une nouvelle ligne et peut s'étendre au-delà d'une ligne.</div>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="custom-file-group">
<label for="multiple-file-de">German File Browser</label>
<div class="custom-file" id="multiple-file-de" lang="de">
<input type="file" class="custom-file-input" id="custom-file-lang-de" multiple>
<label class="custom-file-label" for="custom-file-lang-de">Wähle Dateien</label>
<div class="help-block">Ein Hilfetextblock, der in eine neue Zeile übergeht und über eine Zeile hinausgehen kann.</div>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="custom-file-group">
<label for="multiple-file-he">Hebrew File Browser</label>
<div class="custom-file" id="multiple-file-he" lang="he" dir="rtl">
<input type="file" class="custom-file-input" id="custom-file-lang-he" multiple>
<label class="custom-file-label" for="custom-file-lang-he">לבחור קבצים</label>
<div class="help-block">גוש טקסט עזרה העובר לשורה חדשה ועשוי להימשך מעבר לשורה אחת.</div>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="custom-file-group">
<label for="multiple-file-pl">Polish File Browser</label>
<div class="custom-file" id="multiple-file-pl" lang="pl">
<input type="file" class="custom-file-input" id="custom-file-lang-pl" multiple>
<label class="custom-file-label" for="custom-file-lang-pl">Wybierz pliki</label>
<div class="help-block">Blok tekstu pomocy, który rozpada się na nową linię i może rozciągać się poza jedną linię.</div>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="custom-file-group">
<label for="multiple-file-es">Spanish File Browser</label>
<div class="custom-file" id="multiple-file-es" lang="es">
<input type="file" class="custom-file-input" id="custom-file-lang-es" multiple>
<label class="custom-file-label" for="custom-file-lang-es">Seleccionar archivos</label>
<div class="help-block">Un bloque de texto de ayuda que se divide en una nueva línea y puede extenderse más allá de una línea.</div>
</div>
</div>
</div>
</div>
You’ll need to set the language of your document (or subtree thereof) correctly in order for the correct text to be shown. This can be done using the lang attribute on the <html>
element or the Content-Language HTTP header, among other methods.
When you need to place plain text next to a form label within a form, use the .form-control-static
class on a <p>
.
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<p class="form-control-static">email@example.com</p>
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
</div>
</div>
</form>
<form class="form-inline no-labels">
<div class="form-group">
<label class="sr-only">Email</label>
<p class="form-control-static">email@example.com</p>
</div>
<div class="form-group">
<label for="inputPassword2" class="sr-only">Password</label>
<input type="password" class="form-control" id="inputPassword2" placeholder="Password">
</div>
<button type="submit" class="btn btn-default">Confirm identity</button>
</form>
We remove the default outline
styles on some form controls and apply a box-shadow
in its place for :focus
.
:focus
stateThe above example input uses custom styles in our documentation to demonstrate the :focus
state on a .form-control
.
Add the disabled
boolean attribute on an input to prevent user interactions. Disabled inputs appear lighter and adds a not-allowed
cursor.
<input class="form-control" id="disabledInput" type="text" placeholder="Disabled input here..." disabled>
The disabled styling for a select requires no special markup besides the disabled
boolean attribute.
<select class="form-control" disabled>
...
</select>
Add the disabled
attribute to a <fieldset>
to disable all the controls within the <fieldset>
at once.
<a>
By default, browsers will treat all native form controls (<input>
, <select>
and <button>
elements) inside a <fieldset disabled>
as disabled, preventing both keyboard and mouse interactions on them. However, if your form also includes <a ... class="btn btn-*">
elements, these will only be given a style of pointer-events: none
. As noted in the section about disabled state for buttons (and specifically in the sub-section for anchor elements), this CSS property is not yet standardized and isn't fully supported in Opera 18 and below, or in Internet Explorer 11, and won't prevent keyboard users from being able to focus or activate these links. So to be safe, use custom JavaScript to disable such links.
While Bootstrap will apply these styles in all browsers, Internet Explorer 11 and below don't fully support the disabled
attribute on a <fieldset>
. Use custom JavaScript to disable the fieldset in these browsers.
<form>
<fieldset disabled>
<div class="form-group">
<label for="disabledTextInput">Disabled input</label>
<input type="text" id="disabledTextInput" class="form-control" placeholder="Disabled input">
</div>
<div class="form-group">
<label for="disabledSelect">Disabled select menu</label>
<select id="disabledSelect" class="form-control" disabled>
<option>Disabled select</option>
</select>
</div>
<div class="checkbox">
<label>
<input type="checkbox">
<span></span> Can't check this
</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</fieldset>
</form>
Add the readonly
boolean attribute on an input to prevent modification of the input's value. Read-only inputs appear lighter (just like disabled inputs), but retain the standard cursor.
<input class="form-control" type="text" placeholder="Readonly input here…" readonly>
Block level help text for form controls.
Help text should be explicitly associated with the form control it relates to using the aria-describedby
attribute. This will ensure that assistive technologies – such as screen readers – will announce this help text when the user focuses or enters the control.
<label class="sr-only" for="inputHelpBlock">Input with help text</label>
<input type="text" id="inputHelpBlock" class="form-control" aria-describedby="helpBlock">
<span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>
Form validation is not built into the framework. Use a third party plug-in like the JQuery Validation Plugin to check and make sure forms have required fields completed before submission. See the documentation and demos for further details.
Bootstrap includes validation styles for error, warning, and success states on form controls. To use, add .has-warning
, .has-error
, or .has-success
to the parent element. Any .control-label
, .form-control
, and .help-block
within that element will receive the validation styles.
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
<label>
text itself (as shown below).sr-only
class (see Lexicon examples)aria-invalid="true"
attribute to invalid form controls for assistive technologies<div class="form-group has-success">
<label class="control-label" for="inputSuccess2">Input with success</label>
<input type="text" class="form-control" id="inputSuccess2" aria-describedby="helpBlock2" placeholder="success example">
<span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>
</div>
<div class="form-group has-warning">
<label class="control-label" for="inputWarning2">Input with warning</label>
<input type="text" class="form-control" id="inputWarning2" placeholder="warning example">
</div>
<div class="form-group has-error">
<label class="control-label" for="inputError2">Input with error</label>
<input type="text" class="form-control" id="inputError2" placeholder="error example">
</div>
<div class="form-group has-success">
<label class="control-label" for="textareaSuccess2">Textarea with success</label>
<textarea class="form-control" rows="3" id="textareaSuccess2" aria-describedby="helpBlockTextarea" placeholder="success example"></textarea>
<span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>
</div>
<div class="form-group has-error">
<label class="control-label" for="selectMenuError1">Select menu with error</label>
<select class="form-control">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>
</div>
<div class="has-success">
<div class="checkbox">
<label>
<input type="checkbox" id="checkboxSuccess2" value="option1">
<span></span> Checkbox with success
</label>
</div>
</div>
<div class="has-warning">
<div class="checkbox">
<label>
<input type="checkbox" id="checkboxWarning2" value="option1">
<span></span> Checkbox with warning
</label>
</div>
</div>
<div class="has-error">
<div class="checkbox">
<label>
<input type="checkbox" id="checkboxError2" value="option1">
<span></span> Checkbox with error
</label>
</div>
</div>
<div class="form-group has-error option-group-required">
<fieldset>
<legend>Required radio group with error</legend>
<div class="radio">
<label>
<input type="radio" name="errorRadio" id="errorRadio3" value="1">
<span></span> One thing
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="errorRadio" id="errorRadio4" value="2">
<span></span> Another
</label>
</div>
</fieldset>
<span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>
</div>
If a form is on a dark background, the validation states automatically update to be more visible, with a white background color behind the help block for readability.
If a form is on a light background, the validation states automatically update to be more visible, with a white background color behind the help block for readability.
Use the following approaches to provide feedback after validating a form.
You can also add optional feedback icons with the addition of .has-feedback
and the right icon.
Feedback icons only work with textual <input class="form-control">
elements.
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 .sr-only
class. If you must do without labels, adjust the top
value of the feedback icon. For input groups, adjust the right
value to an appropriate pixel value depending on the width of your addon.
To ensure that assistive technologies – such as screen readers – correctly convey the meaning of an icon, additional hidden text should be included with the .sr-only
class and explicitly associated with the form control it relates to using aria-describedby
. Alternatively, ensure that the meaning (for instance, the fact that there is a warning for a particular text entry field) is conveyed in some other form, such as changing the text of the actual <label>
associated with the form control.
Although the following examples already mention the validation state of their respective form controls in the <label>
text itself, the above technique (using .sr-only
text and aria-describedby
) has been included for illustrative purposes.
<div class="form-group has-success has-feedback">
<label class="control-label" for="input-success-feedback">Input with success</label>
<input type="text" class="form-control" id="input-success-feedback" aria-describedby="input-success-feedback-status">
<span class="icon icon-checkmark form-control-feedback" aria-hidden="true"></span>
<span id="input-success-feedback-status" class="sr-only">(success)</span>
</div>
<div class="form-group has-warning has-feedback">
<label class="control-label" for="input-warning-feedback">Input with warning</label>
<input type="text" class="form-control" id="input-warning-feedback" aria-describedby="input-warning-feedback-status">
<span class="icon icon-warning form-control-feedback" aria-hidden="true"></span>
<span id="input-warning-feedback-status" class="sr-only">(warning)</span>
</div>
<div class="form-group has-error has-feedback">
<label class="control-label" for="input-error-feedback">Input with error</label>
<input type="text" class="form-control" id="input-error-feedback" aria-describedby="input-error-feedback-status">
<span class="icon icon-cancel form-control-feedback" aria-hidden="true"></span>
<span id="input-error-feedback-status" class="sr-only">(error)</span>
</div>
<div class="form-group has-success has-feedback">
<label class="control-label" for="input-group-success-feedback">Input group with success</label>
<div class="input-group">
<span class="input-group-addon">@</span>
<input type="text" class="form-control" id="input-group-success-feedback" aria-describedby="input-group-success-feedback-status">
</div>
<span class="icon icon-checkmark form-control-feedback" aria-hidden="true"></span>
<span id="input-group-success-feedback-status" class="sr-only">(success)</span>
</div>
<form class="form-horizontal">
<div class="form-group has-success has-feedback">
<label class="control-label col-sm-3" for="horizontal-input-success-feedback">Input with success</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="horizontal-input-success-feedback" aria-describedby="horizontal-input-success-feedback-status">
<span class="icon icon-checkmark form-control-feedback" aria-hidden="true"></span>
<span id="horizontal-input-success-feedback-status" class="sr-only">(success)</span>
</div>
</div>
<div class="form-group has-success has-feedback">
<label class="control-label col-sm-3" for="horizontal-input-group-success-feedback">Input group with success</label>
<div class="col-sm-9">
<div class="input-group">
<span class="input-group-addon">@</span>
<input type="text" class="form-control" id="horizontal-input-group-success-feedback" aria-describedby="horizontal-input-group-success-feedback-status">
</div>
<span class="icon icon-checkmark form-control-feedback" aria-hidden="true"></span>
<span id="horizontal-input-group-success-feedback-status" class="sr-only">(success)</span>
</div>
</div>
</form>
<form class="form-inline">
<div class="form-group has-success has-feedback">
<label class="control-label" for="inline-input-success-feedback">Input with success</label>
<input type="text" class="form-control" id="inline-input-success-feedback" aria-describedby="inline-input-success-feedback-status">
<span class="icon icon-checkmark form-control-feedback" aria-hidden="true"></span>
<span id="inline-input-success-feedback-status" class="sr-only">(success)</span>
</div>
</form>
<br>
<form class="form-inline">
<div class="form-group has-success has-feedback">
<label class="control-label" for="inline-input-group-success-feedback">Input group with success</label>
<div class="input-group">
<span class="input-group-addon">@</span>
<input type="text" class="form-control" id="inline-input-group-success-feedback" aria-describedby="inline-input-group-success-feedback-status">
</div>
<span class="icon icon-checkmark form-control-feedback" aria-hidden="true"></span>
<span id="inline-input-group-success-feedback-status" class="sr-only">(success)</span>
</div>
</form>
.sr-only
labelsIf you use the .sr-only
class to hide a form control's <label>
(rather than using other labelling options, such as the aria-label
attribute), Bootstrap will automatically adjust the position of the icon once it's been added.
<div class="form-group has-success has-feedback">
<label class="control-label sr-only" for="input-success-feedback-sr-only-label">Hidden label</label>
<input type="text" class="form-control" id="input-success-feedback-sr-only-label" aria-describedby="input-success-feedback-sr-only-label-status">
<span class="icon icon-checkmark form-control-feedback" aria-hidden="true"></span>
<span id="input-success-feedback-sr-only-label-status" class="sr-only">(success)</span>
</div>
<div class="form-group has-success has-feedback">
<label class="control-label sr-only" for="input-group-success-feedback-sr-only-label">Input group with success</label>
<div class="input-group">
<span class="input-group-addon">@</span>
<input type="text" class="form-control" id="input-group-success-feedback-sr-only-label" aria-describedby="input-group-success-feedback-sr-only-label-status">
</div>
<span class="icon icon-checkmark form-control-feedback" aria-hidden="true"></span>
<span id="input-group-success-feedback-sr-only-label-status" class="sr-only">(success)</span>
</div>
To style required form elements, the .required
class should be applied to the form element's parent div
tag with the class control-group
.
required
HTML attributeAdding the required
attribute to a form tag will not style it as a required element. The element must be a child element of a div
tag with both classes of .control-group
and .required
.
For basic HTML5 validation, the required
attribute also should be added to the specific form element.
<div class="form-group required">
<form>
<div class="form-group required">
<label for="required-stacked-form-email" class="control-label">Email</label>
<input type="email" class="form-control" id="required-stacked-form-email" placeholder="Email">
</div>
<div class="form-group required">
<label for="required-stacked-form-password" class="control-label">Password</label>
<input type="password" class="form-control" id="required-stacked-form-password" placeholder="Password">
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox" value="">
<span></span> Remember me
</label>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-default">Sign in</button>
</div>
</form>
<form class="form-horizontal">
<div class="form-group required">
<label for="required-horizontal-form-email" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="required-horizontal-form-email" placeholder="Email">
</div>
</div>
<div class="form-group required">
<label for="required-horizontal-form-password" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="required-horizontal-form-password" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label>
<input type="checkbox" value="">
<span></span> Remember me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Sign in</button>
</div>
</div>
</form>
<form class="form-inline">
<div class="form-group required">
<label for="required-inline-form-name">Name</label>
<input type="text" class="form-control" id="required-inline-form-name" placeholder="Jane Doe">
</div>
<div class="form-group required">
<label for="required-inline-form-email">Email</label>
<input type="email" class="form-control" id="required-inline-form-email" placeholder="jane.doe@example.com">
</div>
<button type="submit" class="btn btn-default">Send invitation</button>
</form>
required
HTML attribute for radio buttonsFor basic HTML5 validation with radio buttons, the required
attribute should be added to the first radio button input
tag. There is no need to add this to the following radio button input
tags because the browser will interpret that one of them needs to be selected and the required
attribute will applied to each of them.
<div class="form-group option-group-required">
<fieldset>
<legend>Select one of the options below:</legend>
<div class="radio">
<label>
<input type="radio" name="required-option-group-radio-buttons" id="required-option-group-radio-button-1" value="option1" required="required">
<span></span>option 1</label>
</div>
<div class="radio">
<label>
<input type="radio" name="required-option-group-radio-buttons" id="required-option-group-radio-button-2" value="option2">
<span></span>option 2</label>
</div>
</fieldset>
</div>
required
HTML attribute for checkboxesBasic HTML5 validation with a group of checkboxes is not available. To achieve this type of functionality, validation through JavaScript would be required.
The reason JavaScript is needed for this functionality is because the required
attribute cannot be applied to a group of checkboxes as it can for radio buttons. The required
attribute also cannot be applied to a single checkbox input
tag. Doing so would make that specific checkbox required.
<div class="form-group option-group-required">
<fieldset>
<legend>Select one or more of the options below:</legend>
<div class="checkbox">
<label>
<input type="checkbox">
<span></span> Option 1
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox">
<span></span> Option 2
</label>
</div>
</fieldset>
</div>
Set heights using classes like .input-lg
, and set widths using grid column classes like .col-lg-*
.
Create taller or shorter form controls that match button sizes.
<input class="form-control input-lg" type="text" placeholder="Large input">
<input type="text" class="form-control" placeholder="Default input">
<input class="form-control input-sm" type="text" placeholder="Small input">
<div class="select-menu select-menu-lg">
<select class="form-control">
<option value="">Large select</option>
</select>
</div>
<div class="select-menu">
<select class="form-control">
<option value="">Default select</option>
</select>
</div>
<div class="select-menu select-menu-sm">
<select class="form-control">
<option value="">Small select</option>
</select>
</div>
Quickly size labels and form controls within .form-horizontal
by adding .form-group-lg
or .form-group-sm
.
<form class="form-horizontal">
<div class="form-group form-group-lg">
<label class="col-sm-2 control-label" for="formGroupInputLarge">Large label</label>
<div class="col-sm-10">
<input class="form-control" type="text" id="formGroupInputLarge" placeholder="Large input">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="formGroupInputNormal">Normal label</label>
<div class="col-sm-10">
<input class="form-control" type="text" id="formGroupInputNormal" placeholder="Normal input">
</div>
</div>
<div class="form-group form-group-sm">
<label class="col-sm-2 control-label" for="formGroupInputSmall">Small label</label>
<div class="col-sm-10">
<input class="form-control" type="text" id="formGroupInputSmall" placeholder="Small input">
</div>
</div>
</form>
Wrap inputs in grid columns, or any custom parent element, to easily enforce desired widths.
<div class="row">
<div class="col-xs-2">
<input type="text" class="form-control" placeholder=".col-xs-2">
</div>
<div class="col-xs-3">
<input type="text" class="form-control" placeholder=".col-xs-3">
</div>
<div class="col-xs-4">
<input type="text" class="form-control" placeholder=".col-xs-4">
</div>
</div>
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.
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.padding
. That padding is offset in rows for the first and last column via negative margin on .row
s..col-xs-4
..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.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 prefix | .col-xs- |
.col-sm- |
.col-md- |
.col-lg- |
# of columns | 12 | |||
Column width | Auto | ~57px | ~77px | ~92px |
Gutter width | 40px (20px on each side of a column) | |||
Nestable | Yes | |||
Nested gutter width | 20px (10px on each side of a column) | |||
Offsets | Yes | |||
Column ordering | Yes |
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
.
<div class="row">
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
</div>
<div class="row">
<div class="col-md-8">.col-md-8</div>
<div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
<div class="col-md-6">.col-md-6</div>
<div class="col-md-6">.col-md-6</div>
</div>
Because the default grid system is not divisible by five, use a special set of classes to achieve a 5-column grid when needed. Either the 12-column default grid or the 5-column grid may be nested within these as well.
<div class="row">
<div class="col-xs-12 col-sm-1-5 col-md-1-5 col-lg-1-5">.col-md-1-5</div>
<div class="col-xs-12 col-sm-1-5 col-md-1-5 col-lg-1-5">.col-md-1-5</div>
<div class="col-xs-12 col-sm-1-5 col-md-1-5 col-lg-1-5">.col-md-1-5</div>
<div class="col-xs-12 col-sm-1-5 col-md-1-5 col-lg-1-5">.col-md-1-5</div>
<div class="col-xs-12 col-sm-1-5 col-md-1-5 col-lg-1-5">.col-md-1-5</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4-5 col-md-4-5 col-lg-4-5">.col-md-4-5</div>
<div class="col-xs-12 col-sm-1-5 col-md-1-5 col-lg-1-5">.col-md-1-5</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-3-5 col-md-3-5 col-lg-3-5">.col-md-3-5</div>
<div class="col-xs-12 col-sm-2-5 col-md-2-5 col-lg-2-5">.col-md-2-5</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-2-5 col-md-2-5 col-lg-2-5">.col-md-2-5</div>
<div class="col-xs-12 col-sm-1-5 col-md-1-5 col-lg-1-5">.col-md-1-5</div>
<div class="col-xs-12 col-sm-2-5 col-md-2-5 col-lg-2-5">.col-md-2-5</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-1-5 col-md-1-5 col-lg-1-5">.col-md-1-5</div>
<div class="col-xs-12 col-sm-3-5 col-md-3-5 col-lg-3-5">.col-md-3-5</div>
<div class="col-xs-12 col-sm-1-5 col-md-1-5 col-lg-1-5">.col-md-1-5</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-1-5 col-md-1-5 col-lg-1-5">.col-md-1-5</div>
<div class="col-xs-12 col-sm-3-5 col-md-3-5 col-lg-3-5">
Level 1: .col-md-3-5
<div class="row">
<div class="col-xs-6">Level 2: .col-xs-6</div>
<div class="col-xs-6">Level 2: .col-xs-6</div>
</div>
</div>
<div class="col-xs-12 col-sm-1-5 col-md-1-5 col-lg-1-5">.col-md-1-5</div>
</div>
<h3>Column Ordering for the 5-Column Grid</h3>
<div class="row">
<div class="col-md-3-5 col-md-push-2-5">.col-md-3-5 .col-md-push-2-5</div>
<div class="col-md-2-5 col-md-pull-3-5">.col-md-2-5 .col-md-pull-3-5</div>
</div>
Turn any fixed-width grid layout into a full-width layout by changing your outermost .container
to .container-fluid
.
<div class="container-fluid">
<div class="row">
...
</div>
</div>
Don't want your columns to simply stack in smaller devices? Use the extra small and medium device grid classes by adding .col-xs-*
.col-md-*
to your columns. See the example below for a better idea of how it all works.
<!-- Stack the columns on mobile by making one full-width and the other half-width -->
<div class="row">
<div class="col-xs-12 col-md-8">.col-xs-12 .col-md-8</div>
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>
<!-- Columns start at 50% wide on mobile and bump up to 33.3% wide on desktop -->
<div class="row">
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>
<!-- Columns are always 50% wide, on mobile and desktop -->
<div class="row">
<div class="col-xs-6">.col-xs-6</div>
<div class="col-xs-6">.col-xs-6</div>
</div>
Build on the previous example by creating even more dynamic and powerful layouts with tablet .col-sm-*
classes.
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-8">.col-xs-12 .col-sm-6 .col-md-8</div>
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-4">.col-xs-6 .col-sm-4</div>
<div class="col-xs-6 col-sm-4">.col-xs-6 .col-sm-4</div>
<!-- Optional: clear the XS cols if their content doesn't match in height -->
<div class="clearfix visible-xs-block"></div>
<div class="col-xs-6 col-sm-4">.col-xs-6 .col-sm-4</div>
</div>
If more than 12 columns are placed within a single row, each group of extra columns will, as one unit, wrap onto a new line.
<div class="row">
<div class="col-xs-9">.col-xs-9</div>
<div class="col-xs-4">.col-xs-4<br>Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.</div>
<div class="col-xs-6">.col-xs-6<br>Subsequent columns continue along the new line.</div>
</div>
With 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 .clearfix
and our responsive utility classes.
<div class="row">
<div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
<div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
<!-- Add the extra clearfix for only the required viewport -->
<div class="clearfix visible-xs-block"></div>
<div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
<div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
</div>
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.
<div class="row">
<div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
<div class="col-sm-5 col-sm-offset-2 col-md-6 col-md-offset-0">.col-sm-5 .col-sm-offset-2 .col-md-6 .col-md-offset-0</div>
</div>
<div class="row">
<div class="col-sm-6 col-md-5 col-lg-6">.col-sm-6 .col-md-5 .col-lg-6</div>
<div class="col-sm-6 col-md-5 col-md-offset-2 col-lg-6 col-lg-offset-0">.col-sm-6 .col-md-5 .col-md-offset-2 .col-lg-6 .col-lg-offset-0</div>
</div>
Remove the gutters from a row and it's columns with the .row-no-gutters
class.
<div class="row row-no-gutters">
<div class="col-xs-12 col-md-8">.col-xs-12 .col-md-8</div>
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>
<div class="row row-no-gutters">
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>
<div class="row row-no-gutters">
<div class="col-xs-6">.col-xs-6</div>
<div class="col-xs-6">.col-xs-6</div>
</div>
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.
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4 col-md-offset-4">.col-md-4 .col-md-offset-4</div>
</div>
<div class="row">
<div class="col-md-3 col-md-offset-3">.col-md-3 .col-md-offset-3</div>
<div class="col-md-3 col-md-offset-3">.col-md-3 .col-md-offset-3</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">.col-md-6 .col-md-offset-3</div>
</div>
You can also override offsets from lower grid tiers with .col-*-offset-0
classes.
<div class="row">
<div class="col-xs-6 col-sm-4">
</div>
<div class="col-xs-6 col-sm-4">
</div>
<div class="col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-0">
</div>
</div>
To nest your content with the default grid, add a new .row
and set of .col-sm-*
columns within an existing .col-sm-*
column. Nested rows should include a set of columns that add up to 12 or fewer (it is not required that you use all 12 available columns).
<div class="row">
<div class="col-sm-9">
Level 1: .col-sm-9
<div class="row">
<div class="col-xs-8 col-sm-6">
Level 2: .col-xs-8 .col-sm-6
</div>
<div class="col-xs-4 col-sm-6">
Level 2: .col-xs-4 .col-sm-6
</div>
</div>
</div>
</div>
Easily change the order of our built-in grid columns with .col-md-push-*
and .col-md-pull-*
modifier classes.
<div class="row">
<div class="col-md-9 col-md-push-3">.col-md-9 .col-md-push-3</div>
<div class="col-md-3 col-md-pull-9">.col-md-3 .col-md-pull-9</div>
</div>
In addition to prebuilt grid classes for fast layouts, Bootstrap includes Less variables and mixins for quickly generating your own simple, semantic layouts.
Variables 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.
@grid-columns: 12;
@grid-gutter-width: 40px;
@grid-float-breakpoint: 768px;
Mixins are used in conjunction with the grid variables to generate semantic CSS for individual grid columns.
// Creates a wrapper for a series of columns
.make-row(@gutter: @grid-gutter-width) {
// Then clear the floated columns
.clearfix();
@media (min-width: @screen-sm-min) {
margin-left: (@gutter / -2);
margin-right: (@gutter / -2);
}
// Negative margin nested rows out to align the content of columns
.row {
margin-left: (@gutter / -2);
margin-right: (@gutter / -2);
}
}
// Generate the extra small columns
.make-xs-column(@columns; @gutter: @grid-gutter-width) {
position: relative;
// Prevent columns from collapsing when empty
min-height: 1px;
// Inner gutter via padding
padding-left: (@gutter / 2);
padding-right: (@gutter / 2);
// Calculate width based on number of columns available
@media (min-width: @grid-float-breakpoint) {
float: left;
width: percentage((@columns / @grid-columns));
}
}
// Generate the small columns
.make-sm-column(@columns; @gutter: @grid-gutter-width) {
position: relative;
// Prevent columns from collapsing when empty
min-height: 1px;
// Inner gutter via padding
padding-left: (@gutter / 2);
padding-right: (@gutter / 2);
// Calculate width based on number of columns available
@media (min-width: @screen-sm-min) {
float: left;
width: percentage((@columns / @grid-columns));
}
}
// Generate the small column offsets
.make-sm-column-offset(@columns) {
@media (min-width: @screen-sm-min) {
margin-left: percentage((@columns / @grid-columns));
}
}
.make-sm-column-push(@columns) {
@media (min-width: @screen-sm-min) {
left: percentage((@columns / @grid-columns));
}
}
.make-sm-column-pull(@columns) {
@media (min-width: @screen-sm-min) {
right: percentage((@columns / @grid-columns));
}
}
// Generate the medium columns
.make-md-column(@columns; @gutter: @grid-gutter-width) {
position: relative;
// Prevent columns from collapsing when empty
min-height: 1px;
// Inner gutter via padding
padding-left: (@gutter / 2);
padding-right: (@gutter / 2);
// Calculate width based on number of columns available
@media (min-width: @screen-md-min) {
float: left;
width: percentage((@columns / @grid-columns));
}
}
// Generate the medium column offsets
.make-md-column-offset(@columns) {
@media (min-width: @screen-md-min) {
margin-left: percentage((@columns / @grid-columns));
}
}
.make-md-column-push(@columns) {
@media (min-width: @screen-md-min) {
left: percentage((@columns / @grid-columns));
}
}
.make-md-column-pull(@columns) {
@media (min-width: @screen-md-min) {
right: percentage((@columns / @grid-columns));
}
}
// Generate the large columns
.make-lg-column(@columns; @gutter: @grid-gutter-width) {
position: relative;
// Prevent columns from collapsing when empty
min-height: 1px;
// Inner gutter via padding
padding-left: (@gutter / 2);
padding-right: (@gutter / 2);
// Calculate width based on number of columns available
@media (min-width: @screen-lg-min) {
float: left;
width: percentage((@columns / @grid-columns));
}
}
// Generate the large column offsets
.make-lg-column-offset(@columns) {
@media (min-width: @screen-lg-min) {
margin-left: percentage((@columns / @grid-columns));
}
}
.make-lg-column-push(@columns) {
@media (min-width: @screen-lg-min) {
left: percentage((@columns / @grid-columns));
}
}
.make-lg-column-pull(@columns) {
@media (min-width: @screen-lg-min) {
right: percentage((@columns / @grid-columns));
}
}
You 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.
.wrapper {
.make-row();
}
.content-main {
.make-lg-column(8);
}
.content-secondary {
.make-lg-column(3);
.make-lg-column-offset(1);
}
<div class="wrapper">
<div class="content-main">...</div>
<div class="content-secondary">...</div>
</div>
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.
<p class="text-muted">...</p>
<p class="text-primary">...</p>
<p class="text-success">...</p>
<p class="text-info">...</p>
<p class="text-warning">...</p>
<p class="text-danger">...</p>
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 <span>
with the class.
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 .sr-only
class.
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.
<p class="bg-primary">...</p>
<p class="bg-success">...</p>
<p class="bg-info">...</p>
<p class="bg-warning">...</p>
<p class="bg-danger">...</p>
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 <div>
with the class.
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.
<button type="button" class="close" aria-label="Close"><span aria-hidden="true">×</span></button>
Use carets to indicate dropdown functionality and direction. Note that the default caret will reverse automatically in dropup menus.
<span class="caret"></span>
Float an element to the left or right with a class. !important
is included to avoid specificity issues. Classes can also be used as mixins.
<div class="pull-left">...</div>
<div class="pull-right">...</div>
// Classes
.pull-left {
float: left !important;
}
.pull-right {
float: right !important;
}
// Usage as mixins
.element {
.pull-left();
}
.another-element {
.pull-right();
}
Set an element to display: block
and center via margin
. Available as a mixin and class.
<div class="center-block">...</div>
// Class
.center-block {
display: block;
margin-left: auto;
margin-right: auto;
}
// Usage as a mixin
.element {
.center-block();
}
You can also align display:block
elements to the left and right using .left-block
and .right-block
<div class="left-block">...</div>
<div class="right-block">...</div>
// Class
.left-block {
display: block;
margin-left: 0;
margin-right: auto;
}
.right-block {
display: block;
margin-left: auto;
margin-right: 0;
}
These classes utilize the flex properties and reduce the dependency on margin and absolute positioning specifications, which would sometimes result in undesired spacing conflicts.
If you want to center the content within a container, and stack the elements like a column, use .column-align-vertical-center
on the wrapping div. Please note, this will not affect text alignment, so you will need to add .text-center
to your markup if that is the desired layout.
<div class="well well-sm no-shadow bg-black text-center">
<div class="column-align-vertical-center">
<i class="icon icon-download h1 text-b1 margin-bottom-none margin-top-1" aria-hidden="true"></i>
<h2 class="margin-top-none">Drivers & downloads</h2>
</div>
</div>
If you want to center the content within a container, but leave the elements in-line like a row, use .row-align-vertical-center
on the wrapping div. Please note, if you want the items to also align horizontally, the individual items need to be the same height, which can be achieved by adding/removing margin classes on those individual elements.
<div class="well no-shadow bg-black">
<div class="row-align-vertical-center">
<i class="icon icon-download h1 text-b1 margin-bottom-none" aria-hidden="true"> </i>
<h2 class="margin-none">Drivers & downloads</h2>
</div>
</div>
Easily clear float
s by adding .clearfix
to the parent element. Utilizes the micro clearfix as popularized by Nicolas Gallagher. Can also be used as a mixin.
<!-- Usage as a class -->
<div class="clearfix">...</div>
// Mixin itself
.clearfix() {
&:before,
&:after {
content: " ";
display: table;
}
&:after {
clear: both;
}
}
// Usage as a mixin
.element {
.clearfix();
}
Force an element to be shown or hidden (including for screen readers) with the use of .show
and .hidden
classes. These classes use !important
to avoid specificity conflicts, just like the quick floats. They are only available for block level toggling. They can also be used as mixins.
.hide
is available, but it does not always affect screen readers and is deprecated as of v3.0.1. Use .hidden
or .sr-only
instead.
Furthermore, .invisible
can be used to toggle only the visibility of an element, meaning its display
is not modified and the element can still affect the flow of the document.
<div class="show">...</div>
<div class="hidden">...</div>
// Classes
.show {
display: block !important;
}
.hidden {
display: none !important;
}
.invisible {
visibility: hidden;
}
// Usage as mixins
.element {
.show();
}
.another-element {
.hidden();
}
Hide an element to all devices except screen readers with .sr-only
. Combine .sr-only
with .sr-only-focusable
to show the element again when it's focused (e.g. by a keyboard-only user). Necessary for following accessibility best practices. Can also be used as mixins.
<a class="sr-only sr-only-focusable" href="#content">Skip to main content</a>
// Usage as a mixin
.skip-navigation {
.sr-only();
.sr-only-focusable();
}
Utilize the .text-hide
class or mixin to help replace an element's text content with a background image.
<h1 class="text-hide">Custom heading</h1>
// Usage as a mixin
.heading {
.text-hide();
}
Specific padding classes used when extra (or less) spacing is required for a component or column. These modifier classes naming convention are in steps from 1-4.
These alternate padding styles break default layouts set within the framework and should be used with caution. Any break from the standard grid should be thoughtful and as always, backed by sound reasoning.
For all other cases use the base component padding.
The modifier classes for full padding are Deprecated: .l-pad-*
, whereas *
is a number from 1-10
. New: .padding-*
, whereas *
is a number from 1-6
and an additional class of .padding-none
to remove any padding.
The modifier classes for full margins are the same as full padding but with a class of .margin-*
instead of a classe of .padding-*
<div class="well padding-none">
...
</div>
<div class="well margin-none">
...
</div>
The modifier classes for top and bottom padding are Deprecated: .l-pad-top-*
and .l-pad-bottom-*
, whereas *
is a number from 1-10
. New: .padding-*
whereas *
is a number from 1-6
and additional classes of .padding-top-none
and .padding-bottom-none
to remove any top/bottom padding.
The modifier classes for top and bottom are the same as padding but with a class of .margin-*
instead of a classe of .padding-*
<div class="well padding-top-2">
...
</div>
<div class="well margin-top-2">
...
</div>
The modifier classes for before and after padding are Deprecated: .l-pad-before-*
and .l-pad-after-*
, whereas *
is a number from 1-10
. New: .padding-*
whereas *
is a number from 1-6
and additional classes of .padding-before-none
and .padding-after-none
to remove any before/after padding.
The modifier classes for before and after margins are the same as padding but with a class of .margin-*
instead of a classe of .padding-*
<div class="well padding-before-4">
...
</div>
<div class="well margin-before-4">
...
</div>
All padding or margins may be removed by using any of the screen size classes.
In some rare cases, you may need to set the position property on a container to accomodate alignments or other positioning needs. Rather than use inline styles, we have provided basic classes that you may use:
.absolute
= position: absolute !important
.relative
= position: relative !important
Use these classes to add and remove borders, change their colors and/or thickness. Multiple classes can be applied at one time to achieve a desired design pattern.
To add individual borders to a div, apply .border-top
, .border-after
, .border-bottom
and/or .border-before
. These classes can be used individually or in combination with one another.
<div class="border-top">
...
</div>
If a border is needed for all sides of a div, use the class .border-all
instead of adding each border-side class individually.
<div class="border-all">
...
</div>
Any color from our color palette can be applied to a border. To achieve this design pattern, add the border position class(es) first and then an additional border class with the suffix color name.
<div class="border-top border-b1">
...
</div>
The default border size is set to 1px, but if a thicker border is needed there is a 4px option. To achieve this design pattern, add the border position class(es) first and then an additional border class with the suffix -thick
.
<div class="border-top border-thick">
...
</div>
All borders may be hidden by using any of the screen size classes: .border-hidden-xs
, .border-hidden-sm
, .border-hidden-md
, .border-hidden-lg
.
<div class="border-all border-hidden-xs">
...
</div>
<div class="border-all border-hidden-sm">
...
</div>
<div class="border-all border-hidden-md">
...
</div>
<div class="border-all border-hidden-lg">
...
</div>
Hide individual sides by adding the suffix -hidden-xs
, -hidden-sm
, -hidden-md
, -hidden-lg
to the desired side class.
<div class="border-all border-before-hidden-xs">
...
</div>
<div class="border-all border-before-hidden-sm">
...
</div>
<div class="border-all border-before-hidden-md">
...
</div>
<div class="border-all border-before-hidden-lg">
...
</div>
Use the classes below when you need to remove a border from a pre-existing bordered element, such as wells, tabs, accordions, etc.
<div class="well border-top-none">
.border-top-none
</div>
<div class="well border-after-none">
.border-after-none
</div>
<div class="well border-bottom-none">
.border-bottom-none
</div>
<div class="well border-before-none">
.border-before-none
</div>
<div class="well border-none">
.border-none
</div>
Images in Bootstrap 3 can be made responsive-friendly via the addition of the .img-responsive
class. This applies max-width: 100%;
, height: auto;
and display: block;
to the image so that it scales nicely to the parent element.
To center images which use the .img-responsive
class, use .center-block
instead of .text-center
. See the helper classes section for more details about .center-block
usage.
In Internet Explorer 8-10, SVG images with .img-responsive
are disproportionately sized. To fix this, add width: 100% \9;
where necessary. Bootstrap doesn't apply this automatically as it causes complications to other image formats.
<img src="..." class="img-responsive" alt="Responsive image">
Add classes to an <img>
element to easily style images in any project.
<img src="..." alt="..." class="">
<img src="..." alt="..." class="img-rounded">
<img src="..." alt="..." class="img-circle">
<img src="..." alt="..." class="img-thumbnail">
<img src="..." alt="..." class="img-thumbnail img-thumbnail--square">
Image sizes should try to adhere to the 12px vertical rhythm by having heights divisible by 12.
Currently support scaling of an image with hover.
<img src="..." class="img-scale" alt="...">
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.
Extra small devices Phones (<768px) | Small devices Tablets (≥768px) | Medium devices Desktops (≥992px) | Large devices Desktops (≥1200px) | |
---|---|---|---|---|
.visible-xs-* |
Visible | Hidden | Hidden | Hidden |
.visible-sm-* |
Hidden | Visible | Hidden | Hidden |
.visible-md-* |
Hidden | Hidden | Visible | Hidden |
.visible-lg-* |
Hidden | Hidden | Hidden | Visible |
.hidden-xs |
Hidden | Visible | Visible | Visible |
.hidden-sm |
Visible | Hidden | Visible | Visible |
.hidden-md |
Visible | Visible | Hidden | Visible |
.hidden-lg |
Visible | Visible | Visible | Hidden |
As of v3.2.0, the .visible-*-*
classes for each breakpoint come in three variations, one for each CSS display
property value listed below.
Group of classes | CSS display |
---|---|
.visible-*-block |
display: block; |
.visible-*-inline |
display: inline; |
.visible-*-inline-block |
display: inline-block; |
So, for extra small (xs
) screens for example, the available .visible-*-*
classes are: .visible-xs-block
, .visible-xs-inline
, and .visible-xs-inline-block
.
The classes .visible-xs
, .visible-sm
, .visible-md
, and .visible-lg
also exist, but are deprecated as of v3.2.0. They are approximately equivalent to .visible-*-block
, except with additional special cases for toggling <table>
-related elements.
Similar to the regular responsive classes, use these for toggling content for print.
Classes | Browser | |
---|---|---|
.visible-print-block .visible-print-inline .visible-print-inline-block
|
Hidden | Visible |
.hidden-print |
Visible | Hidden |
The class .visible-print
also exists but is deprecated as of v3.2.0. It is approximately equivalent to .visible-print-block
, except with additional special cases for <table>
-related elements.
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.
Here, green checkmarks also indicate the element is hidden in your current viewport.
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 |
<table class="table">
...
</table>
As a default, the content within a table row is vertically aligned with the top of the parent. You can apply .align-bottom
or .align-center
to the <th>
and/or <td>
to achieve different layouts.
Media | A6, Oficio, Universal, Statement, Letter, Legal, JIS-B5, Folio, Executive, DL Envelope, C5 Envelope, B5 Envelope, A5, A4, 9 Envelope, 7 3/4 Envelope, 10 Envelope |
---|---|
Part Number | 40C9500 |
Function(s) |
|
<table class="table">
<tbody>
<tr>
<th scope="row">Media</th>
<td>...</td>
</tr>
<tr>
<th scope="row">Part Number</th>
<td class="align-center">40C9500</td>
</tr>
<tr>
<th scope="row" class="align-bottom">Function(s)</th>
<td>...</td>
</tr>
</tbody>
</table>
Use .table-striped
to add zebra-striping to any table row within the <tbody>
.
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 |
<table class="table table-striped">
...
</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 |
<table class="table table-bordered">
...
</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 |
<table class="table table-condensed">
...
</table>
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 |
<table class="table table-hover">
...
</table>
Use the .btn-xs
and .btn-ghost
to style the buttons. Add icons where applicable for a quick scan and to provide better context. The buttons must be wrapped in a div and use .btn-nowrap
.
# | First Name | Last Name | Actions |
---|---|---|---|
1 | Mark | Otto |
|
2 | Jacob | Thornton |
|
3 | Larry | the Bird |
|
<table class="table table-condensed table-bordered">
<thead>
...
</thead>
<tbody>
<tr>
<th>...</th>
<td>...</td>
<td>...</td>
<td>
<div class="btn-nowrap">
<button type="button" class="btn btn-ghost btn-xs"><i class="icon icon-link" aria-hidden="true"></i> Link</button>
</div>
</td>
</tr>
</tbody>
</table>
Use contextual classes to color table rows or individual cells.
Class | Description |
---|---|
.active
|
Applies the hover color to a particular row or cell |
.success
|
Indicates a successful or positive action |
.info
|
Indicates a neutral informative change or action |
.warning
|
Indicates a warning that might need attention |
.danger
|
Indicates a dangerous or potentially negative action |
# | Column heading | Column heading | Column heading |
---|---|---|---|
1 | Column content | Column content | Column content |
2 | Column content | Column content | Column content |
3 | Column content | Column content | Column content |
4 | Column content | Column content | Column content |
5 | Column content | Column content | Column content |
6 | Column content | Column content | Column content |
7 | Column content | Column content | Column content |
8 | Column content | Column content | Column content |
9 | Column content | Column content | Column content |
<!-- On rows -->
<tr class="active">...</tr>
<tr class="success">...</tr>
<tr class="info">...</tr>
<tr class="warning">...</tr>
<tr class="danger">...</tr>
<!-- On cells (`td` or `th`) -->
<tr>
<td class="active">...</td>
<td class="success">...</td>
<td class="info">...</td>
<td class="warning">...</td>
<td class="danger">...</td>
</tr>
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 .sr-only
class.
Tables can be interactive and allow form elements within table cells.
# | First Name | Last Name | User Group |
---|---|---|---|
1 |
|
|
|
2 |
|
|
|
<table class="table table-hover">
<thead>
...
</thead>
<tbody>
<!-- EXAMPLE CONTEXTUAL ROW -->
<tr class="danger">
<th scope="row">1</th>
<!-- EXAMPLE WITH TEXTAREA -->
<td role="cell" headers="product-model">
<div class="form-group">
<textarea class="form-control input-sm" placeholder="Mark" spellcheck="true" aria-label="First name"></textarea>
</div>
</td>
<!-- EXAMPLE WITH TEXTAREA -->
<td>
<div class="form-group">
<textarea class="form-control input-sm" placeholder="Otto" spellcheck="true" aria-label="Last name"></textarea>
</div>
</td>
<!-- EXAMPLE WITH SELECT AND ERRORS -->
<td role="cell" headers="user-group">
<div class="form-group has-error">
<select id="user-group-cell-with-errors" name="choose-user-group" class="form-control select-sm" aria-label="Choose user group" aria-expanded="false" title="">
<option disabled selected>Choose User Group</option>
<option value="Groups">Writer</option>
<option value="Option">Developer</option>
<option value="Part">Designer</option>
<option value="Printer">Manager</option>
<option value="Supply">Support</option>
</select>
</div>
</td>
</tr>
<tr>
<th scope="row">2</th>
<!-- EXAMPLE WITH INPUT -->
<td>
<div class="form-group form-group-sm">
<input type="text" class="form-control" id="input-first-name" placeholder="Lary" spellcheck="true" aria-label="First name">
</div>
</td>
<!-- EXAMPLE WITH INPUT -->
<td>
<div class="form-group form-group-sm">
<input type="text" class="form-control" id="input-last-name" placeholder="the bird" spellcheck="true" aria-label="Last name">
</div>
</td>
<!-- EXAMPLE WITH SELECT -->
<td>
<div class="form-group">
<select id="user-group-cell-no-errors" name="choose-user-group" class="form-control select-sm" aria-label="Choose user group" aria-expanded="false" title="">
<option disabled>Choose User Group</option>
<option value="Groups">Writer</option>
<option value="Option" selected>Developer</option>
<option value="Part">Designer</option>
<option value="Printer">Manager</option>
<option value="Supply">Support</option>
</select>
</div>
</td>
</tr>
</tbody>
</table>
Create responsive tables by wrapping any .table
in .table-responsive
to make them scroll horizontally on small devices (under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.
Responsive tables make use of overflow-y: hidden
, which clips off any content that goes beyond the bottom or top edges of the table. In particular, this can clip off dropdown menus and other third-party widgets.
Firefox has some awkward fieldset styling involving width
that interferes with the responsive table. This cannot be overridden without a Firefox-specific hack that we don't provide in Bootstrap:
@-moz-document url-prefix() {
fieldset { display: table-cell; }
}
For more information, read this Stack Overflow answer.
# | Table heading | Table heading | Table heading | Table heading | Table heading | Table heading |
---|---|---|---|---|---|---|
1 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
2 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
3 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
# | Table heading | Table heading | Table heading | Table heading | Table heading | Table heading |
---|---|---|---|---|---|---|
1 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
2 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
3 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
<div class="table-responsive">
<table class="table">
...
</table>
</div>
Create sortable tables by adding .table-sortable
to any table
to allow table to be sorted based on column input.
Sortable tables make use of third-party jQuery plugin tablesorter 2.0 to make it work properly.
For more information, read the plugin documentation.
# | Name | Currency | Date |
---|---|---|---|
2 | Jerry | $1.00 | 05/04/2015 |
1 | Bruce | $32.50 | 01/01/2015 |
3 | Clark | -$99.21 | 01/12/2016 |
<table class="table table-sortable">
...
</table>
Add .table-cards
to display table rows as cards. This will create a grid of 12 columns which you can fill in with cards. You will need to add breakpoint classes to the <tr>
elements as well
Icon | Name |
---|---|
Linux | |
OSX | |
Windows | |
Google+ |
<table class="table table-cards">
<tbody>
<tr class="card-xs-6 card-sm-4 card-md-3 card-lg-2">
...
</tr>
<tr class="card-xs-6 card-sm-4 card-md-3 card-lg-2">
...
</tr>
<tr class="card-xs-6 card-sm-4 card-md-3 card-lg-2">
...
</tr>
...
</tbody>
</table>
You can create a toggle between cards and a standard table by adding/removing the .table-cards
class from the <table>
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 jumbo heading |
2.985984rem / 4.5rem 47.7757px / 72px |
h1 heading |
2.0736rem / 3rem 33.1776px / 48px |
h2 heading |
1.728rem / 2.625rem 27.648px / 42px |
h3 heading |
1.44rem / 2.25rem 23.04px / 36px |
h4 heading |
1.2rem / 1.875rem 19.2px / 30px |
h5 heading |
1rem / 1.5rem 16px / 24px |
h6 heading |
0.8333333333rem / 1.3125rem 13.3333px / 21px |
<h1 class="jumbo">h1 jumbo heading</h1>
<h1>h1 heading</h1>
<h2>h2 heading</h2>
<h3>h3 heading</h3>
<h4>h4 heading</h4>
<h5>h5 heading</h5>
<h6>h6 heading</h6>
Create lighter, secondary text in any heading with a generic <small>
tag or the .small
class.
h1 jumbo heading Secondary text |
h1 heading Secondary text |
h2 heading Secondary text |
h3 heading Secondary text |
h4 heading Secondary text |
h5 heading Secondary text |
h6 heading Secondary text |
<h1 class="jumbo">h1 jumbo heading <small>Secondary text</small>
<h1>h1 heading <small>Secondary text</small></h1>
<h2>h2 heading <small>Secondary text</small></h2>
<h3>h3 heading <small>Secondary text</small></h3>
<h4>h4 heading <small>Secondary text</small></h4>
<h5>h5 heading <small>Secondary text</small></h5>
<h6>h6 heading <small>Secondary text</small></h6>
Wrap the number heading in a <div>
tag with the class .number-heading
. Use <span>
tags to enclose each section as shown below, using .number
, .prefix
, .infix
, and .suffix
. For the suffix section, if text is needed, use the .suffix-text
class or .suffix-text-block
to keep all of the text on a separate line. Due to limitations of HTML markup, all <span>
sections must not contain any spaces between each section.
Use the class .symbol
to stylize any of three sections: prefix, infix, or suffix.
Horizontal alignment can be achieved by using the current text alignment classes. For vertical alignment of any of the three sections, add .valign-top
or .valign-center
. The default vertical alignment is bottom. Vertical alignment is not available for the .number
section.
<div class="number-heading text-b8 text-light">
<span class="number">88</span><span class="suffix symbol">%</span>
</div>
<div class="number-heading text-b8 text-light">
<span class="number">88</span><span class="suffix symbol valign-top">%</span>
</div>
In Persian and Turkish, the percent sign precedes the number.
<div class="number-heading text-b8 text-light">
<span class="prefix symbol valign-top">%</span><span class="number">88</span>
</div>
Use the class .symbol
to signify currency values. The class .cent
may also be used to show a decimal value. The typical vertical alignment classes may be applied to either of these.
<div class="number-heading text-b3 text-light">
<span class="prefix symbol valign-top">$</span><span class="number">57</span>
</div>
<div class="number-heading text-b3 text-light">
<span class="prefix symbol valign-top">$</span><span class="number">32</span><span class="suffix cent">.95</span>
</div>
<div class="number-heading text-b3 text-light">
<span class="number">32</span><span class="suffix cent valign-top">.95</span><span class="suffix symbol valign-top">$</span>
</div>
<div class="number-heading text-b3 text-light">
<span class="prefix symbol valign-top">€</span><span class="number">27</span><span class="suffix cent valign-top">.94</span>
</div>
<div class="number-heading text-b3 text-light">
<span class="number">27</span><span class="suffix cent valign-top">.94</span><span class="suffix symbol valign-top">€</span>
</div>
Text may be placed in either the middle (.infix
) or the end (.suffix
) sections. The typical vertical alignment classes may be applied to either of these. If the text should begin on a separate line below the number, use the .suffix-text-block
<div class="number-heading text-b7 text-light">
<span class="number">1</span><span class="infix valign-center">out of</span><span class="number">4</span>
</div>
<div class="number-heading text-b7 text-light">
<span class="number">4</span><span class="infix">of</span><span class="number">5</span>
</div>
<div class="number-heading text-b7 text-light">
<span class="number">3</span><span class="suffix suffix-text">million</span>
</div>
<div class="number-heading text-b7 text-light">
<span class="number">3</span><span class="suffix suffix-text-block">million</span>
</div>
LXCore's global default font-size
is 16px, with a line-height
of 1.5 (24px). 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.
<p>...</p>
Make a paragraph stand out by adding .lead
.
Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus.
<p class="lead">...</p>
The typographic scale is based on two Sass variables: @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.
This equally distributes content across multiple columns. The .column-fill-*
classes need to be applied to the parent element to work as expected. For example, if you are dividing an unordered list across multiple columns the .column-fill-*
classes need to be applied to the <ul>
tag. Additional examples of implementation are below.
CSS Columns are not supported in Internet Explorer 9 and below. These browsers will show one column
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum rhoncus, purus sit amet facilisis molestie, magna diam ultricies erat, eu scelerisque turpis sapien ac nunc. Ut nec neque scelerisque quam efficitur tincidunt id sit amet velit. Vestibulum accumsan luctus urna. Suspendisse sed pulvinar lorem.
<div class="column-fill-xs-2">
<p>Lorem ipsum dolor sit amet...</p>
</div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum rhoncus, purus sit amet facilisis molestie, magna diam ultricies erat, eu scelerisque turpis sapien ac nunc. Ut nec neque scelerisque quam efficitur tincidunt id sit amet velit. Vestibulum accumsan luctus urna. Suspendisse sed pulvinar lorem.
<div class="column-fill-xs-3">
<p>Lorem ipsum dolor sit amet...</p>
</div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum rhoncus, purus sit amet facilisis molestie, magna diam ultricies erat, eu scelerisque turpis sapien ac nunc. Ut nec neque scelerisque quam efficitur tincidunt id sit amet velit. Vestibulum accumsan luctus urna. Suspendisse sed pulvinar lorem.
Curabitur ornare varius enim, porta pellentesque est maximus pretium. Integer est magna, commodo nec mi eget, molestie bibendum arcu. Morbi eget purus non magna suscipit malesuada. Sed vel nunc tortor. Etiam vel lectus a metus fermentum sollicitudin. Suspendisse blandit massa vitae tortor consequat, a efficitur lorem vehicula.
Maecenas dictum, mi vitae condimentum rutrum, libero odio tincidunt lectus, in eleifend arcu ligula id purus. Ut tempus lectus ut massa tincidunt, at ullamcorper nulla volutpat. In rhoncus tincidunt dui non elementum. Sed ut tortor tempus, auctor justo eu, lobortis urna. Curabitur at rutrum est. In rhoncus ipsum mauris, id blandit orci efficitur tincidunt. Donec ultricies tempor consequat. Nullam tristique ornare ligula eget tempus.
<div class="column-fill-xs-2">
<p>Lorem ipsum dolor sit amet...</p>
<p>Curabitur ornare varius enim...</p>
<p>Maecenas dictum, mi vitae...</p>
</div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum rhoncus, purus sit amet facilisis molestie, magna diam ultricies erat, eu scelerisque turpis sapien ac nunc. Ut nec neque scelerisque quam efficitur tincidunt id sit amet velit. Vestibulum accumsan luctus urna. Suspendisse sed pulvinar lorem.
Curabitur ornare varius enim, porta pellentesque est maximus pretium. Integer est magna, commodo nec mi eget, molestie bibendum arcu. Morbi eget purus non magna suscipit malesuada. Sed vel nunc tortor. Etiam vel lectus a metus fermentum sollicitudin. Suspendisse blandit massa vitae tortor consequat, a efficitur lorem vehicula.
Maecenas dictum, mi vitae condimentum rutrum, libero odio tincidunt lectus, in eleifend arcu ligula id purus. Ut tempus lectus ut massa tincidunt, at ullamcorper nulla volutpat. In rhoncus tincidunt dui non elementum. Sed ut tortor tempus, auctor justo eu, lobortis urna. Curabitur at rutrum est. In rhoncus ipsum mauris, id blandit orci efficitur tincidunt. Donec ultricies tempor consequat. Nullam tristique ornare ligula eget tempus.
<div class="column-fill-sm-2 column-fill-md-3 column-fill-lg-4">
<p>Lorem ipsum dolor sit amet...</p>
<p>Curabitur ornare varius enim...</p>
<p>Maecenas dictum, mi vitae...</p>
</div>
You need to add .column-fill-btn-list
to the <ul>
for button hover states to stay within their designated rows.
<ul class="list-unstyled column-fill-xs-2 column-fill-btn-list">
<li><a href="#" class="btn btn-primary btn-block btn-sm" role="button">Button 1</a></li>
<li><a href="#" class="btn btn-primary btn-block btn-sm" role="button">Button 2</a></li>
<li><a href="#" class="btn btn-primary btn-block btn-sm" role="button">Button 3</a></li>
<li><a href="#" class="btn btn-primary btn-block btn-sm" role="button">Button 4</a></li>
<li><a href="#" class="btn btn-primary btn-block btn-sm" role="button">Button 5</a></li>
<li><a href="#" class="btn btn-primary btn-block btn-sm" role="button">Button 6</a></li>
</ul>
For highlighting a run of text due to its relevance in another context, use the <mark>
tag.
You can use the mark tag to highlight text.
You can use the mark tag to <mark>highlight</mark> text.
For indicating blocks of text that have been deleted use the <del>
tag.
This line of text is meant to be treated as deleted text.
<del>This line of text is meant to be treated as deleted text.</del>
For indicating blocks of text that are no longer relevant use the <s>
tag.
This line of text is meant to be treated as no longer accurate.
<s>This line of text is meant to be treated as no longer accurate.</s>
For indicating additions to the document use the <ins>
tag.
This line of text is meant to be treated as an addition to the document.
<ins>This line of text is meant to be treated as an addition to the document.</ins>
To underline text use the <u>
tag.
This line of text will render as underlined
<u>This line of text will render as underlined</u>
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.
You may alternatively use an inline element with .small
in place of any <small>
.
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.</small>
For emphasizing a snippet of text with a heavier font-weight.
The following snippet of text is rendered as bold text.
<strong>rendered as bold text</strong>
For emphasizing a snippet of text with italics.
The following snippet of text is rendered as italicized text.
<em>rendered as italicized text</em>
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.
Change body text sizes using the LxCore ratio (1.2) with size classes.
Large Text |
(same size as h4) 1.2rem / 1.875rem 19.2px / 30px |
Default Text |
(same size as h5) 1rem / 1.5rem 16px / 24px |
Small Text |
(same size as h6) 0.8333333333rem / 1.3125rem 13.3333px / 21px |
Tiny Text |
0.6944444444rem / 1.125rem 11.1111px / 18px |
<p class="text-large">Large Text</p>
<p>Default Sized Text</p>
<p class="text-small">Small Text</p>
<p class="text-tiny">Tiny Text</p>
Easily realign text to components with text alignment classes.
Left aligned text.
Center aligned text.
Right aligned text.
Justified text.
No wrap text.
<p class="text-left">Left aligned text.</p>
<p class="text-center">Center aligned text.</p>
<p class="text-right">Right aligned text.</p>
<p class="text-justify">Justified text.</p>
<p class="text-nowrap">No wrap text.</p>
Use the following classes when overflow of text impedes user experience.
Using .break-word
will break a word at arbitrary points if there are no otherwise acceptable break points in the line. Generally only use when a word break symbol would cause misinterpretation, such as when breaking a long URL.
Using .break-word-hyphens
will break the word using a hyphen between the breaks.
Using .break-word-ellipsis
will truncate the words that begin to overflow their container and will add an ellipsis. This option should only be used if the user can access all of the text through other means.
The ellipsis truncation class should be applied to a single line of text and must be applied to an inline-block element. If .break-word-ellipsis
is applied to a block level element, the text will be limited to one line and no ellipsis will be shown.
The examples below show a border to help illustrate the overflow problem with a long single word if no breaks are applied.
No symbols
Hyphens
Ellipsis
Default (no classes)
...
<div class="row">
<div class="col-xs-3 border-all break-word">
Recyclingzwecken an Lexmark zurückzugeben. Tinte/Toner & Verbrauchsmaterialien. Rechtsschutzversicherungsgesellschaften
</div>
<div class="col-xs-3 border-all break-word-hyphens">
Recyclingzwecken an Lexmark zurückzugeben. Tinte/Toner & Verbrauchsmaterialien. Rechtsschutzversicherungsgesellschaften
</div>
<div class="col-xs-3 border-all break-word-ellipsis">
Recyclingzwecken an Lexmark zurückzugeben. Tinte/Toner & Verbrauchsmaterialien. Rechtsschutzversicherungsgesellschaften
</div>
<div class="col-xs-3 border-all">
Recyclingzwecken an Lexmark zurückzugeben. Tinte/Toner & Verbrauchsmaterialien. Rechtsschutzversicherungsgesellschaften
</div>
</div>
...
Because both the table and its cell will expand to fill its container based upon its content, word break classes will only work on a cell if the cell has a max-width set. The table will also need its width set to its initial value to ignore the default 100% width.
No symbols | Hyphens | Ellipsis |
---|---|---|
Recyclingzwecken an Lexmark zurückzugeben. Tinte/Toner & Verbrauchsmaterialien. Rechtsschutzversicherungsgesellschaften | Recyclingzwecken an Lexmark zurückzugeben. Tinte/Toner & Verbrauchsmaterialien. Rechtsschutzversicherungsgesellschaften | Recyclingzwecken an Lexmark zurückzugeben. Tinte/Toner & Verbrauchsmaterialien. Rechtsschutzversicherungsgesellschaften |
Default (no classes) | Empty |
---|---|
Recyclingzwecken an Lexmark zurückzugeben. Tinte/Toner & Verbrauchsmaterialien. Rechtsschutzversicherungsgesellschaften |
<table class="table table-bordered" style="width: initial">
<thead>
<tr>
<th scope="col" style="max-width: 200px">No symbols</th>
<th scope="col" style="max-width: 200px">Hyphens</th>
<th scope="col" style="max-width: 200px">Ellipsis</th>
</tr>
</thead>
<tbody>
<tr>
<td class="break-word" style="max-width: 200px">Recyclingzwecken an Lexmark zurückzugeben. Tinte/Toner & Verbrauchsmaterialien. Rechtsschutzversicherungsgesellschaften</td>
<td class="break-word-hyphens" style="max-width: 200px">Recyclingzwecken an Lexmark zurückzugeben. Tinte/Toner & Verbrauchsmaterialien. Rechtsschutzversicherungsgesellschaften</td>
<td class="break-word-ellipsis" style="max-width: 200px">Recyclingzwecken an Lexmark zurückzugeben. Tinte/Toner & Verbrauchsmaterialien. Rechtsschutzversicherungsgesellschaften</td>
</tr>
</tbody>
</table>
<table class="table table-bordered" style="width: initial">
<thead>
<tr>
<th scope="col" style="max-width: 200px">Default (no classes)</th>
<th scope="col" style="width: 200px; max-width: 200px">Empty</th>
</tr>
</thead>
<tbody>
<tr>
<td style="max-width: 200px">Recyclingzwecken an Lexmark zurückzugeben. Tinte/Toner & Verbrauchsmaterialien. Rechtsschutzversicherungsgesellschaften</td>
<td style="width: 200px; max-width: 200px"> </td>
</tr>
</tbody>
</table>
Transform text in components with text capitalization classes.
Lowercased text.
Uppercased text.
Capitalized text.
<p class="text-lowercase">Lowercased text.</p>
<p class="text-uppercase">Uppercased text.</p>
<p class="text-capitalize">Capitalized text.</p>
Text thick and thin to beef up or slim down text.
Text bold.
Text semibold.
Text thick.
Text light.
<p class="text-bold">Text bold.</p>
<p class="text-semibold">Text semibold.</p>
<p class="text-thick">Text thick.</p>
<p class="text-light">Text light.</p>
Stylized implementation 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 and to users of assistive technologies.
An abbreviation of the word attribute is attr.
<abbr title="attribute">attr</abbr>
Add .initialism
to an abbreviation for a slightly smaller font-size.
HTML is the best thing since sliced bread.
<abbr title="HyperText Markup Language" class="initialism">HTML</abbr>
Present contact information for the nearest ancestor or the entire body of work. Preserve formatting by ending all lines with <br>
.
<address>
<strong>Twitter, Inc.</strong><br>
1355 Market Street, Suite 900<br>
San Francisco, CA 94103<br>
<abbr title="Phone">P:</abbr> (123) 456-7890
</address>
<address>
<strong>Full Name</strong><br>
<a href="mailto:#">first.last@example.com</a>
</address>
"Normal" quotes are part of the presented text, and aren't meant to be highlighted as more or less important than surrounding content.
John Doe said, CSS rocks big time!
<p>John Doe said, <q cite="#linkToSource">CSS rocks big time!</q></p>
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>
Add a <footer>
for identifying the source. Wrap the name of the source work in <cite>
and order the Quotee Name, Title, and Company as seen below.
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>
<footer>
<cite title="Source Title"><a href="#">Source Title</a></cite><br>
<strong>Quotee Name</strong><br>
Quotee Title<br>
Quotee Company
</footer>
</blockquote>
Add .blockquote-reverse
for a blockquote with right-aligned content.
<blockquote class="blockquote-reverse">
...
</blockquote>
Add .border-b1
to <blockquote>
, changing b1 to any color in our framework.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
<blockquote class="border-b1">
...
</blockquote>
Add .text-white
to <blockquote>
. If the default link color doesn't meet accessibility standards against the background color, add .text-white
to <a>
. Works with any color in our framework.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
<blockquote class="text-white">
...
<cite title="Source Title"><a class="text-white" href="#">Source Title</a></cite><br>
...
</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>
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.
<ul class="list-unstyled">
<li>...</li>
</ul>
Add .list-condensed
to the <ul>
to remove the bottom margin from each list item.
<ul class="list-condensed">
<li>...</li>
</ul>
Place all list items on a single line with display: inline-block;
and some light padding.
<ul class="list-inline">
<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. Starts off stacked like default <dl>
s, but when the navbar expands, so do these.
<dl class="dl-horizontal">
<dt>...</dt>
<dd>...</dd>
</dl>