Bootstrap 3 Tutorial

Must Watch!



MustWatch



Bootstrap is the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites. Bootstrap is completely free to download and use!

Try it Yourself Examples

This Bootstrap tutorial contains hundreds of Bootstrap examples. With our online editor, you can edit the code, and click on a button to view the result.

Bootstrap Example

<div class="jumbotron text-center"> <h1>My First Bootstrap Page</h1> <p>Resize this responsive page to see the effect!</p> </div> <div class="container"> <div class="row"> <div class="col-sm-4"> <h3>Column 1</h3> <p>Lorem ipsum dolor..</p> </div> <div class="col-sm-4"> <h3>Column 2</h3> <p>Lorem ipsum dolor..</p> </div> <div class="col-sm-4"> <h3>Column 3</h3> <p>Lorem ipsum dolor..</p> </div> </div> </div> Try it Yourself » Click on the "Try it Yourself" button to see how it works.

Bootstrap Exercises

Test Yourself With Exercises

Exercise:

Add the correct class name to transform the list below into a pagination menu. <ul class=""> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> </ul> Start the Exercise

Bootstrap Quiz Test

Test your Bootstrap skills at W3Schools! Start Bootstrap Quiz!

Bootstrap References

At W3Schools you will find a complete Bootstrap reference of all CSS classes, Components, and JavaScript plugins - all with "Try it Yourself" examples: Complete List of All Bootstrap ClassesPopular Bootstrap CSS Text/Typography Bootstrap CSS Buttons Bootstrap CSS Forms Bootstrap CSS Helpers Bootstrap CSS Images Bootstrap CSS Tables Bootstrap Components Dropdowns Bootstrap Components Navs Bootstrap Components Glyphicons Bootstrap JS Affix Bootstrap JS Alert Bootstrap JS Button Bootstrap JS Carousel Bootstrap JS Collapse Bootstrap JS Dropdown Bootstrap JS Modal Bootstrap JS Popover Bootstrap JS Scrollspy Bootstrap JS Tab Bootstrap JS Tooltip

Bootstrap Themes / Templates

We have made some Bootstrap Templates you can play around with. They are completely free to use: Theme Company Browse Themes Templates Browse Basic Templates

Bootstrap 3 vs. Bootstrap 4

Bootstrap 4 is the newest version of Bootstrap; with new components, faster stylesheet and more responsiveness. Bootstrap 4 supports the latest, stable releases of all major browsers and platforms. However, Internet Explorer 9 and down is not supported. If you require IE8-9 support, use Bootstrap 3. It is the most stable version of Bootstrap, and it is still supported by the team for critical bugfixes and documentation changes. However, no new features will be added to it. Go To Bootstrap 4 »

Did You Know?

W3.CSS is an excellent alternative to Bootstrap. W3.CSS is smaller, faster, and easier to use. If you want to learn W3.CSS, go to our W3.CSS Tutorial.

Bootstrap Get Started

What is Bootstrap?

  • Bootstrap is a free front-end framework for faster and easier web development
  • Bootstrap includes HTML and CSS based design templates for typography, forms, buttons, tables, navigation, modals, image carousels and many other, as well as optional JavaScript plugins
  • Bootstrap also gives you the ability to easily create responsive designs
  • What is Responsive Web Design? Responsive web design is about creating web sites which automatically adjust themselves to look good on all devices, from small phones to large desktops.

    Bootstrap Example

    <div class="jumbotron text-center"> <h1>My First Bootstrap Page</h1> <p>Resize this responsive page to see the effect!</p> </div> <div class="container"> <div class="row"> <div class="col-sm-4"> <h3>Column 1</h3> <p>Lorem ipsum dolor..</p> </div> <div class="col-sm-4"> <h3>Column 2</h3> <p>Lorem ipsum dolor..</p> </div> <div class="col-sm-4"> <h3>Column 3</h3> <p>Lorem ipsum dolor..</p> </div> </div> </div> Try it Yourself »

    Bootstrap History

    Bootstrap was developed by Mark Otto and Jacob Thornton at Twitter, and released as an open source product in August 2011 on GitHub. In June 2014 Bootstrap was the No.1 project on GitHub!

    Why Use Bootstrap?

    Advantages of Bootstrap:
  • Easy to use: Anybody with just basic knowledge of HTML and CSS can start using Bootstrap
  • Responsive features: Bootstrap's responsive CSS adjusts to phones, tablets, and desktops
  • Mobile-first approach: In Bootstrap 3, mobile-first styles are part of the core framework
  • Browser compatibility: Bootstrap is compatible with all modern browsers (Chrome, Firefox, Internet Explorer, Edge, Safari, and Opera)
  • Where to Get Bootstrap?

    There are two ways to start using Bootstrap on your own web site. You can:
  • Download Bootstrap from getbootstrap.com
  • Include Bootstrap from a CDN
  • Downloading Bootstrap

    If you want to download and host Bootstrap yourself, go to getbootstrap.com, and follow the instructions there.

    Bootstrap CDN

    If you don't want to download and host Bootstrap yourself, you can include it from a CDN (Content Delivery Network). MaxCDN provides CDN support for Bootstrap's CSS and JavaScript. You must also include jQuery:

    MaxCDN:

    <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <!-- jQuery library --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <!-- Latest compiled JavaScript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> One advantage of using the Bootstrap CDN: Many users already have downloaded Bootstrap from MaxCDN when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time. jQuery Bootstrap uses jQuery for JavaScript plugins (like modals, tooltips, etc). However, if you just use the CSS part of Bootstrap, you don't need jQuery.

    Create First Web Page With Bootstrap

    1. Add the HTML5 doctype Bootstrap uses HTML elements and CSS properties that require the HTML5 doctype. Always include the HTML5 doctype at the beginning of the page, along with the lang attribute and the correct character set: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> </head> </html> 2. Bootstrap 3 is mobile-first Bootstrap 3 is designed to be responsive to mobile devices. Mobile-first styles are part of the core framework. To ensure proper rendering and touch zooming, add the following <meta> tag inside the <head> element: <meta name="viewport" content="width=device-width, initial-scale=1"> The width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device). The initial-scale=1 part sets the initial zoom level when the page is first loaded by the browser. 3. Containers Bootstrap also requires a containing element to wrap site contents. There are two container classes to choose from:
    1. The .container class provides a responsive fixed width container
    2. The .container-fluid class provides a full width container, spanning the entire width of the viewport
    .container .container-fluid

    Two Basic Bootstrap Pages

    The following example shows the code for a basic Bootstrap page (with a responsive fixed width container):

    Example

    <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h1>My First Bootstrap Page</h1> <p>This is some text.</p> </div> </body> </html> Try it Yourself » The following example shows the code for a basic Bootstrap page (with a full width container):

    Example

    <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> </head> <body> <div class="container-fluid"> <h1>My First Bootstrap Page</h1> <p>This is some text.</p> </div> </body> </html> Try it Yourself »

    Bootstrap Grids

    Bootstrap Grid System

    Bootstrap's grid system allows up to 12 columns across the page. If you do not want to use all 12 columns individually, you can group the columns together to create wider columns:
    span 1span 1 span 1span 1span 1 span 1span 1span 1 span 1span 1span 1 span 1
    span 4 span 4 span 4
    span 4span 8
    span 6span 6
    span 12
    Bootstrap's grid system is responsive, and the columns will re-arrange automatically depending on the screen size.

    Grid Classes

    The Bootstrap grid system has four classes:
  • xs (for phones - screens less than 768px wide)
  • sm (for tablets - screens equal to or greater than 768px wide)
  • md (for small laptops - screens equal to or greater than 992px wide)
  • lg (for laptops and desktops - screens equal to or greater than 1200px wide)
  • The classes above can be combined to create more dynamic and flexible layouts.

    Basic Structure of a Bootstrap Grid

    The following is a basic structure of a Bootstrap grid: <div class="row"> <div class="col-*-*"></div> <div class="col-*-*"></div> </div> <div class="row"> <div class="col-*-*"></div> <div class="col-*-*"></div> <div class="col-*-*"></div> </div> <div class="row"> ... </div> First; create a row (<div class="row">). Then, add the desired number of columns (tags with appropriate .col-*-* classes). Note that numbers in .col-*-* should always add up to 12 for each row. Below we have collected some examples of basic Bootstrap grid layouts.

    Three Equal Columns

    .col-sm-4 .col-sm-4 .col-sm-4 The following example shows how to get a three equal-width columns starting at tablets and scaling to large desktops. On mobile phones or screens that are less than 768px wide, the columns will automatically stack:

    Example

    <div class="row"> <div class="col-sm-4">.col-sm-4</div> <div class="col-sm-4">.col-sm-4</div> <div class="col-sm-4">.col-sm-4</div> </div> Try it Yourself »

    Two Unequal Columns

    .col-sm-4 .col-sm-8 The following example shows how to get two various-width columns starting at tablets and scaling to large desktops:

    Example

    <div class="row"> <div class="col-sm-4">.col-sm-4</div> <div class="col-sm-8">.col-sm-8</div> </div> Try it Yourself » Tip: You will learn more about Bootstrap grids later in this tutorial.

    Bootstrap Text/Typography

    Bootstrap's Default Settings

    Bootstrap's global default font-size is 14px, with a line-height of 1.428. This is applied to the <body> element and all paragraphs (<p>). In addition, all <p> elements have a bottom margin that equals half their computed line-height (10px by default).

    Bootstrap vs. Browser Defaults

    In this chapter, we will look at some HTML elements that will be styled a little bit differently by Bootstrap than browser defaults.

    <h1> - <h6>

    By default, Bootstrap will style the HTML headings (<h1> to <h6>) in the following way:

    Example

    h1 Bootstrap heading (36px)

    h2 Bootstrap heading (30px)

    h3 Bootstrap heading (24px)

    h4 Bootstrap heading (18px)

    h5 Bootstrap heading (14px)
    h6 Bootstrap heading (12px)
    Try it Yourself »

    <small>

    In Bootstrap the HTML <small> element is used to create a lighter, secondary text in any heading:

    Example

    h1 heading secondary text

    h2 heading secondary text

    h3 heading secondary text

    h4 heading secondary text

    h5 heading secondary text
    h6 heading secondary text
    Try it Yourself »

    <mark>

    Bootstrap will style the HTML <mark> element in the following way:

    Example

    Use the mark element to highlight text. Try it Yourself »

    <abbr>

    Bootstrap will style the HTML <abbr> element in the following way:

    Example

    The WHO was founded in 1948. Try it Yourself »

    <blockquote>

    Bootstrap will style the HTML <blockquote> element in the following way:

    Example

    For 50 years, WWF has been protecting the future of nature. The world's leading conservation organization, WWF works in 100 countries and is supported by 1.2 million members in the United States and close to 5 million globally.
    From WWF's website
    Try it Yourself » To show the quote on the right, use the .blockquote-reverse class:

    Example

    For 50 years, WWF has been protecting the future of nature. The world's leading conservation organization, WWF works in 100 countries and is supported by 1.2 million members in the United States and close to 5 million globally.
    From WWF's website
    Try it Yourself »

    <dl>

    Bootstrap will style the HTML <dl> element in the following way:

    Example

    Coffee
    - black hot drink
    Milk
    - white cold drink
    Try it Yourself »

    <code>

    Bootstrap will style the HTML <code> element in the following way:

    Example

    The following HTML elements: span, section, and div defines a section in a document. Try it Yourself »

    <kbd>

    Bootstrap will style the HTML <kbd> element in the following way:

    Example

    Use ctrl + p to open the Print dialog box. Try it Yourself »

    <pre>

    Bootstrap will style the HTML <pre> element in the following way:

    Example

    Text in a pre element is displayed in a fixed-width font, and it preserves both spaces and line breaks. Try it Yourself »

    Contextual Colors and Backgrounds

    Bootstrap also has some contextual classes that can be used to provide "meaning through colors". The classes for text colors are:.text-muted, .text-primary, .text-success, .text-info, .text-warning, and .text-danger:

    Example

    This text is muted. This text is important. This text indicates success. This text represents some information. This text represents a warning. This text represents danger. Try it Yourself » The classes for background colors are:.bg-primary, .bg-success, .bg-info, .bg-warning, and .bg-danger:

    Example

    This text is important. This text indicates success. This text represents some information. This text represents a warning. This text represents danger. Try it Yourself »

    More Typography Classes

    The Bootstrap classes below can be added to style HTML elements further:
    ClassDescriptionExample
    .leadMakes a paragraph stand outTry it
    .smallIndicates smaller text (set to 85% of the size of the parent)Try it
    .text-leftIndicates left-aligned textTry it
    .text-centerIndicates center-aligned textTry it
    .text-rightIndicates right-aligned textTry it
    .text-justifyIndicates justified textTry it
    .text-nowrapIndicates no wrap textTry it
    .text-lowercaseIndicates lowercased textTry it
    .text-uppercaseIndicates uppercased textTry it
    .text-capitalizeIndicates capitalized textTry it
    .initialismDisplays the text inside an <abbr> element in a slightly smaller font sizeTry it
    .list-unstyledRemoves the default list-style and left margin on list items (works on both <ul> and <ol>). This class only applies to immediate children list items (to remove the default list-style from any nested lists, apply this class to any nested lists as well)Try it
    .list-inlinePlaces all list items on a single lineTry it
    .dl-horizontalLines up the terms (<dt>) and descriptions (<dd>) in <dl> elements side-by-side. Starts off like default <dl>s, but when the browser window expands, it will line up side-by-sideTry it
    .pre-scrollableMakes a <pre> element scrollableTry it

    Complete Bootstrap Typography Reference

    For a complete reference of all typography elements/classes, go to our complete Bootstrap Typography Reference. Also look at our Bootstrap Helper Classes Reference for more information about contextual classes.

    Bootstrap Tables

    Bootstrap Basic Table

    A basic Bootstrap table has a light padding and only horizontal dividers. The .table class adds basic styling to a table:

    Example

    Firstname Lastname Email
    JohnDoejohn@example.com
    MaryMoemary@example.com
    JulyDooleyjuly@example.com
    Try it Yourself »

    Striped Rows

    The .table-striped class adds zebra-stripes to a table:

    Example

    Firstname Lastname Email
    JohnDoejohn@example.com
    MaryMoemary@example.com
    JulyDooleyjuly@example.com
    Try it Yourself »

    Bordered Table

    The .table-bordered class adds borders on all sides of the table and cells:

    Example

    Firstname Lastname Email
    JohnDoejohn@example.com
    MaryMoemary@example.com
    JulyDooleyjuly@example.com
    Try it Yourself »

    Hover Rows

    The .table-hover class adds a hover effect (grey background color) on table rows:

    Example

    Firstname Lastname Email
    JohnDoejohn@example.com
    MaryMoemary@example.com
    JulyDooleyjuly@example.com
    Try it Yourself »

    Condensed Table

    The .table-condensed class makes a table more compact by cutting cell padding in half:

    Example

    Firstname Lastname Email
    JohnDoejohn@example.com
    MaryMoemary@example.com
    JulyDooleyjuly@example.com
    Try it Yourself »

    Contextual Classes

    Contextual classes can be used to color table rows (<tr>) or table cells (<td>):

    Example

    Firstname Lastname Email
    Default Defaultson def@somemail.com
    Success Doe john@example.com
    Danger Moe mary@example.com
    Info Dooley july@example.com
    Warning Refs bo@example.com
    Active Activeson act@example.com
    Try it Yourself » The contextual classes that can be used are:
    Class Description
    .activeApplies the hover color to the table row or table cell
    .successIndicates a successful or positive action
    .infoIndicates a neutral informative change or action
    .warningIndicates a warning that might need attention
    .dangerIndicates a dangerous or potentially negative action

    Responsive Tables

    The .table-responsive class creates a responsive table. The table will then scroll horizontally on small devices (under 768px). When viewing on anything larger than 768px wide, there is no difference:

    Example

    <div class="table-responsive"> <table> ... </table> </div> Try it Yourself »

    Test Yourself With Exercises

    Exercise:

    Add a class attribute to style the table as a basic Bootstrap table. <table > <tr> <td>John</td> <td>Doe</td> <td>john@example.com</td> <tr> <tr> <td>Mary</td> <td>Moe</td> <td>mary@example.com</td> </tr> <tr> <td>July</td> <td>Dooley</td> <td>july@example.com</td> </tr> <table> Start the Exercise

    Complete Bootstrap Table Reference

    For a complete reference of all table classes, go to our complete Bootstrap Tables Reference.

    Bootstrap Images

    Bootstrap Image Shapes

    Rounded Corners: Cinque Terre Circle: Cinque Terre Thumbnail: Cinque Terre

    Rounded Corners

    The .img-rounded class adds rounded corners to an image (IE8 does not support rounded corners):

    Example

    <img src="cinqueterre.jpg" class="img-rounded" alt="Cinque Terre"> Try it Yourself »

    Circle

    The .img-circle class shapes the image to a circle (IE8 does not support rounded corners):

    Example

    <img src="cinqueterre.jpg" class="img-circle" alt="Cinque Terre"> Try it Yourself »

    Thumbnail

    The .img-thumbnail class shapes the image to a thumbnail:

    Example

    <img src="cinqueterre.jpg" class="img-thumbnail" alt="Cinque Terre"> Try it Yourself »

    Responsive Images

    Images come in all sizes. So do screens. Responsive images automatically adjust to fit the size of the screen. Create responsive images by adding an .img-responsive class to the <img> tag. The image will then scale nicely to the parent element. The .img-responsive class applies display: block; and max-width: 100%; and height: auto; to the image:

    Example

    <img class="img-responsive" src="img_chania.jpg" alt="Chania"> Try it Yourself »

    Image Gallery

    You can also use Bootstrap's grid system in conjunction with the .thumbnail class to create an image gallery. Lorem ipsum donec id elit non mi porta gravida at eget metus. Lorem ipsum donec id elit non mi porta gravida at eget metus. Lorem ipsum donec id elit non mi porta gravida at eget metus. Note: You will learn more about the Grid System later in this tutorial (how to create a layout with different amount of columns).

    Example

    <div class="row"> <div class="col-md-4"> <div class="thumbnail"> <a href="/w3images/lights.jpg"> <img src="/w3images/lights.jpg" alt="Lights" style="width:100%"> <div class="caption"> <p>Lorem ipsum...</p> </div> </a> </div> </div> <div class="col-md-4"> <div class="thumbnail"> <a href="/w3images/nature.jpg"> <img src="/w3images/nature.jpg" alt="Nature" style="width:100%"> <div class="caption"> <p>Lorem ipsum...</p> </div> </a> </div> </div> <div class="col-md-4"> <div class="thumbnail"> <a href="/w3images/fjords.jpg"> <img src="/w3images/fjords.jpg" alt="Fjords" style="width:100%"> <div class="caption"> <p>Lorem ipsum...</p> </div> </a> </div> </div> </div> Try it Yourself »

    Responsive Embeds

    Also let videos or slideshows scale properly on any device. Classes can be applied directly to <iframe>, <embed>, <video>, and <object> elements. The following example creates a responsive video by adding an .embed-responsive-item class to an <iframe> tag (the video will then scale nicely to the parent element). The containing <div> defines the aspect ratio of the video:

    Example

    <div class="embed-responsive embed-responsive-16by9"> <iframe class="embed-responsive-item" src="..."></iframe> </div> Try it Yourself » What is aspect ratio? The aspect ratio of an image describes the proportional relationship between its width and its height. Two common video aspect ratios are 4:3 (the universal video format of the 20th century), and 16:9 (universal for HD television and European digital television). You can choose between two aspect ratio classes: <!-- 16:9 aspect ratio --> <div class="embed-responsive embed-responsive-16by9"> <iframe class="embed-responsive-item" src="..."></iframe> </div> <!-- 4:3 aspect ratio --> <div class="embed-responsive embed-responsive-4by3"> <iframe class="embed-responsive-item" src="..."></iframe> </div> Try it Yourself »

    Test Yourself With Exercises

    Exercise:

    Use a Bootstrap class to shape the image as a circle. <img src="img_chania.jpg">"> Start the Exercise

    Complete Bootstrap Image Reference

    For a complete reference of all image classes, go to our complete Bootstrap Image Reference.

    Bootstrap Jumbotron and Page Header

    Creating a Jumbotron

    A jumbotron indicates a big box for calling extra attention to some special content or information. A jumbotron is displayed as a grey box with rounded corners. It also enlarges the font sizes of the text inside it. Tip: Inside a jumbotron you can put nearly any valid HTML, including other Bootstrap elements/classes. Use a <div> element with class .jumbotron to create a jumbotron:

    Bootstrap Tutorial

    Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web.

    Jumbotron Inside Container

    Place the jumbotron inside the <div class="container"> if you want the jumbotron to NOT extend to the edge of the screen:

    Example

    <div class="container"> <div class="jumbotron"> <h1>Bootstrap Tutorial</h1> <p>Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web.</p> </div> <p>This is some text.</p> <p>This is another text.</p> </div> Try it Yourself »

    Jumbotron Outside Container

    Place the jumbotron outside the <div class="container"> if you want the jumbotron to extend to the screen edges:

    Example

    <div class="jumbotron"> <h1>Bootstrap Tutorial</h1> <p>Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web.</p> </div> <div class="container"> <p>This is some text.</p> <p>This is another text.</p> </div> Try it Yourself »

    Creating a Page Header

    A page header is like a section divider. The .page-header class adds a horizontal line under the heading (+ adds some extra space around the element):

    Example Page Header

    Use a <div> element with class .page-header to create a page header:

    Example

    <div class="page-header"> <h1>Example Page Header</h1> </div> Try it Yourself »

    Bootstrap Wells

    Wells

    The .well class adds a rounded border around an element with a gray background color and some padding: Basic Well

    Example

    <div class="well">Basic Well</div> Try it Yourself »

    Well Size

    Small Well Normal Well Large Well Change the size of the well by adding the .well-sm class for small wells or .well-lg class for large wells:

    Example

    <div class="well well-sm">Small Well</div> <div class="well well-lg">Large Well</div> Try it Yourself » By default, wells are medium in size.

    Bootstrap Alerts

    Alerts

    Bootstrap provides an easy way to create predefined alert messages: × Success! This alert box indicates a successful or positive action. × Info! This alert box indicates a neutral informative change or action. × Warning! This alert box indicates a warning that might need attention. × Danger! This alert box indicates a dangerous or potentially negative action. Alerts are created with the .alert class, followed by one of the four contextual classes .alert-success, .alert-info, .alert-warning or .alert-danger:

    Example

    <div class="alert alert-success"> <strong>Success!</strong> Indicates a successful or positive action. </div> <div class="alert alert-info"> <strong>Info!</strong> Indicates a neutral informative change or action. </div> <div class="alert alert-warning"> <strong>Warning!</strong> Indicates a warning that might need attention. </div> <div class="alert alert-danger"> <strong>Danger!</strong> Indicates a dangerous or potentially negative action. </div> Try it Yourself »

    Alert Links

    Add the alert-link class to any links inside the alert box to create "matching colored links": Success! You should read this message. Info! You should read this message. Warning! You should read this message. Danger! You should read this message.

    Example

    <div class="alert alert-success"> <strong>Success!</strong> You should <a href="#" class="alert-link">read this message</a>. </div> Try it Yourself »

    Closing Alerts

    × Click on the "x" symbol to the right to close me. To close the alert message, add a .alert-dismissible class to the alert container. Then add class="close" and data-dismiss="alert" to a link or a button element (when you click on this the alert box will disappear).

    Example

    <div class="alert alert-success alert-dismissible"> <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> <strong>Success!</strong> Indicates a successful or positive action. </div> Try it Yourself » The aria-* attribute and &times; explanation To help improve accessibility for people using screen readers, you should include the aria-label="close" attribute, when creating a close button. &times; (×) is an HTML entity that is the preferred icon for close buttons, rather than the letter "x". For a list of all HTML Entities, visit our HTML Entities Reference.

    Animated Alerts

    × Click on the "x" symbol to the right to close me. I will "fade" out. The .fade and .in classes adds a fading effect when closing the alert message:

    Example

    <div class="alert alert-danger fade in"> Try it Yourself »

    Test Yourself With Exercises

    Exercise:

    Add a Bootstrap "alert" class to display the result of a successful action. <div class=""> Success! </div> Start the Exercise

    Complete Bootstrap Alert Reference

    For a complete reference of all alert options, methods and events, go to our Bootstrap JS Alert Reference.

    Bootstrap Buttons

    Button Styles

    Bootstrap provides different styles of buttons: To achieve the button styles above, Bootstrap has the following classes:
  • .btn
  • .btn-default
  • .btn-primary
  • .btn-success
  • .btn-info
  • .btn-warning
  • .btn-danger
  • .btn-link
  • The following example shows the code for the different button styles:

    Example

    <button type="button" class="btn">Basic</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-success">Success</button> <button type="button" class="btn btn-info">Info</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> Try it Yourself » The button classes can be used on an <a>, <button>, or <input> element:

    Example

    <a href="#" class="btn btn-info" role="button">Link Button</a> <button type="button" class="btn btn-info">Button</button> <input type="button" class="btn btn-info" value="Input Button"> <input type="submit" class="btn btn-info" value="Submit Button"> Try it Yourself » Why do we put a # in the href attribute of the link? Since we do not have any page to link it to, and we do not want to get a "404" message, we put # as the link in our examples. It should be a real URL to a specific page. Bootstrap provides four button sizes: The classes that define the different sizes are:
  • .btn-lg
  • .btn-sm
  • .btn-xs
  • The following example shows the code for different button sizes:

    Example

    <button type="button" class="btn btn-primary btn-lg">Large</button> <button type="button" class="btn btn-primary">Normal</button> <button type="button" class="btn btn-primary btn-sm">Small</button> <button type="button" class="btn btn-primary btn-xs">XSmall</button> Try it Yourself »

    Block Level Buttons

    A block level button spans the entire width of the parent element. Add class .btn-block to create a block level button:

    Example

    <button type="button" class="btn btn-primary btn-block">Button 1</button> Try it Yourself »

    Active/Disabled Buttons

    A button can be set to an active (appear pressed) or a disabled (unclickable) state: The class .active makes a button appear pressed, and the class .disabled makes a button unclickable:

    Example

    <button type="button" class="btn btn-primary active">Active Primary</button> <button type="button" class="btn btn-primary disabled">Disabled Primary</button> Try it Yourself »

    Test Yourself With Exercises

    Exercise:

    Add a Bootstrap class to style the button properly as a "danger" button. <button class="">Danger</button> Start the Exercise

    Complete Bootstrap Button Reference

    For a complete reference of all button classes, go to our complete Bootstrap Button Reference.

    Bootstrap Button Groups

    Button Groups

    Bootstrap allows you to group a series of buttons together (on a single line) in a button group: Use a <div> element with class .btn-group to create a button group:

    Example

    <div class="btn-group"> <button type="button" class="btn btn-primary">Apple</button> <button type="button" class="btn btn-primary">Samsung</button> <button type="button" class="btn btn-primary">Sony</button> </div> Try it Yourself » Tip: Instead of applying button sizes to every button in a group, use class .btn-group-lg|sm|xs to size all buttons in the group:

    Example

    <div class="btn-group btn-group-lg"> <button type="button" class="btn btn-primary">Apple</button> <button type="button" class="btn btn-primary">Samsung</button> <button type="button" class="btn btn-primary">Sony</button> </div> Try it Yourself »

    Vertical Button Groups

    Bootstrap also supports vertical button groups: Use the class .btn-group-vertical to create a vertical button group:

    Example

    <div class="btn-group-vertical"> <button type="button" class="btn btn-primary">Apple</button> <button type="button" class="btn btn-primary">Samsung</button> <button type="button" class="btn btn-primary">Sony</button> </div> Try it Yourself » To span the entire width of the screen, use the .btn-group-justified class: Example with <a> elements:

    Example

    <div class="btn-group btn-group-justified"> <a href="#" class="btn btn-primary">Apple</a> <a href="#" class="btn btn-primary">Samsung</a> <a href="#" class="btn btn-primary">Sony</a> </div> Try it Yourself » Note: For <button> elements, you must wrap each button in a .btn-group class:

    Example

    <div class="btn-group btn-group-justified"> <div class="btn-group"> <button type="button" class="btn btn-primary">Apple</button> </div> <div class="btn-group"> <button type="button" class="btn btn-primary">Samsung</button> </div> <div class="btn-group"> <button type="button" class="btn btn-primary">Sony</button> </div> </div> Try it Yourself »

    Nesting Button Groups & Dropdown Menus

  • Tablet
  • Smartphone
  • Nest button groups to create dropdown menus:

    Example

    <div class="btn-group"> <button type="button" class="btn btn-primary">Apple</button> <button type="button" class="btn btn-primary">Samsung</button> <div class="btn-group"> <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown"> Sony <span class="caret"></span></button> <ul class="dropdown-menu" role="menu"> <li><a href="#">Tablet</a></li> <li><a href="#">Smartphone</a></li> </ul> </div> </div> Try it Yourself »

    Split Button Dropdowns

  • Tablet
  • Smartphone
  • Example

    <div class="btn-group"> <button type="button" class="btn btn-primary">Sony</button> <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown"> <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li><a href="#">Tablet</a></li> <li><a href="#">Smartphone</a></li> </ul> </div> Try it Yourself »

    Test Yourself With Exercises

    Exercise:

    Add a Bootstrap class to group the buttons together. <div class=""> <button class="btn btn-primary">Apple</button> <button class="btn btn-primary">Samsung</button> <button class="btn btn-primary">Sony</button> </div> Start the Exercise

    Bootstrap Glyphicons

    Glyphicons

    Bootstrap provides 260 glyphicons from the Glyphicons Halflings set. Glyphicons can be used in text, buttons, toolbars, navigation, forms, etc. Here are some examples of glyphicons: Envelope glyphicon: Print glyphicon: Search glyphicon: Download glyphicon:

    Glyphicon Syntax

    A glyphicon is inserted with the following syntax: <span class="glyphicon glyphicon-name"></span> The name part in the syntax above must be replaced with the proper name of the glyphicon.

    Glyphicon Example

    The following example shows different ways to use glyphicons:

    Example

    <p>Envelope icon: <span class="glyphicon glyphicon-envelope"></span></p> <p>Envelope icon as a link: <a href="#"><span class="glyphicon glyphicon-envelope"></span></a> </p> <p>Search icon: <span class="glyphicon glyphicon-search"></span></p> <p>Search icon on a button: <button type="button" class="btn btn-default"> <span class="glyphicon glyphicon-search"></span> Search </button> </p> <p>Search icon on a styled button: <button type="button" class="btn btn-info"> <span class="glyphicon glyphicon-search"></span> Search </button> </p> <p>Print icon: <span class="glyphicon glyphicon-print"></span></p> <p>Print icon on a styled link button: <a href="#" class="btn btn-success btn-lg"> <span class="glyphicon glyphicon-print"></span> Print </a> </p> Try it Yourself »

    Test Yourself With Exercises

    Exercise:

    Use a Glyphicon class value to make the span display as a "search" icon. <span class=""></span> Start the Exercise

    Complete Bootstrap Glyphicon Reference

    For a complete reference of all glyphicons, go to our complete Bootstrap Glyphicon Reference.

    Bootstrap Badges and Labels

    Badges

    Badges are numerical indicators of how many items are associated with a link: News 5 Comments 10 Updates 2 The numbers (5, 10, and 2) are the badges. Use the .badge class within <span> elements to create badges:

    Example

    <a href="#">News <span class="badge">5</span></a><br> <a href="#">Comments <span class="badge">10</span></a><br> <a href="#">Updates <span class="badge">2</span></a> Try it Yourself » Badges can also be used inside other elements, such as buttons: The following example shows how to add badges to buttons:

    Example

    <button type="button" class="btn btn-primary">Primary <span class="badge">7</span></button> Try it Yourself »

    Labels

    Labels are used to provide additional information about something:

    Example New

    Example New

    Example New

    Example New

    Example New
    Example New
    Use the .label class, followed by one of the six contextual classes .label-default, .label-primary, .label-success, .label-info, .label-warning or .label-danger, within a <span> element to create a label:

    Example

    <h1>Example <span class="label label-default">New</span></h1> <h2>Example <span class="label label-default">New</span></h2> <h3>Example <span class="label label-default">New</span></h3> <h4>Example <span class="label label-default">New</span></h4> <h5>Example <span class="label label-default">New</span></h5> <h6>Example <span class="label label-default">New</span></h6> Try it Yourself » The following example shows all contextual label classes: Default Label Primary Label Success Label Info Label Warning Label Danger Label

    Example

    <span class="label label-default">Default Label</span> <span class="label label-primary">Primary Label</span> <span class="label label-success">Success Label</span> <span class="label label-info">Info Label</span> <span class="label label-warning">Warning Label</span> <span class="label label-danger">Danger Label</span> Try it Yourself »

    Test Yourself With Exercises

    Exercise:

    After the "Comments" text, use a span element to make a badge with the number two inside. <button>Comments </button> Start the Exercise

    Bootstrap Progress Bars

    Basic Progress Bar

    A progress bar can be used to show a user how far along he/she is in a process. Bootstrap provides several types of progress bars. A default progress bar in Bootstrap looks like this:
    70% Complete
    To create a default progress bar, add a .progress class to a <div> element:

    Example

    <div class="progress"> <div class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:70%"> <span class="sr-only">70% Complete</span> </div> </div> Try it Yourself » Note: Progress bars are not supported in Internet Explorer 9 and earlier (because they use CSS3 transitions and animations to achieve some of their effects). Note: To help improve accessibility for people using screen readers, you should include the aria-* attributes.

    Progress Bar With Label

    A progress bar with a label looks like this:
    70%
    Remove the .sr-only class from the progress bar to show a visible percentage:

    Example

    <div class="progress"> <div class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:70%"> 70% </div> </div> Try it Yourself »

    Colored Progress Bars

    Contextual classes are used to provide "meaning through colors". The contextual classes that can be used with progress bars are:
  • .progress-bar-success
  • .progress-bar-info
  • .progress-bar-warning
  • .progress-bar-danger
  • 40% Complete (success) 50% Complete (info) 60% Complete (warning) 70% Complete (danger) The following example shows how to create progress bars with the different contextual classes:

    Example

    <div class="progress"> <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%"> 40% Complete (success) </div> </div> <div class="progress"> <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width:50%"> 50% Complete (info) </div> </div> <div class="progress"> <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:60%"> 60% Complete (warning) </div> </div> <div class="progress"> <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:70%"> 70% Complete (danger) </div> </div> Try it Yourself »

    Striped Progress Bars

    Progress bars can also be striped: 40% Complete (success) 50% Complete (info) 60% Complete (warning) 70% Complete (danger) Add class .progress-bar-striped to add stripes to the progress bars:

    Example

    <div class="progress"> <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%"> 40% Complete (success) </div> </div> <div class="progress"> <div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width:50%"> 50% Complete (info) </div> </div> <div class="progress"> <div class="progress-bar progress-bar-warning progress-bar-striped" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:60%"> 60% Complete (warning) </div> </div> <div class="progress"> <div class="progress-bar progress-bar-danger progress-bar-striped" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:70%"> 70% Complete (danger) </div> </div> Try it Yourself »

    Animated Progress Bar

    40% Add class .active to animate the progress bar:

    Example

    <div class="progress"> <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%"> 40% </div> </div> Try it Yourself »

    Stacked Progress Bars

    Progress bars can also be stacked: Free Space Warning Danger Create a stacked progress bar by placing multiple bars into the same <div class="progress">:

    Example

    <div class="progress"> <div class="progress-bar progress-bar-success" role="progressbar" style="width:40%"> Free Space </div> <div class="progress-bar progress-bar-warning" role="progressbar" style="width:10%"> Warning </div> <div class="progress-bar progress-bar-danger" role="progressbar" style="width:20%"> Danger </div> </div> Try it Yourself »

    Test Yourself With Exercises

    Exercise:

    Add the correct classes to make this HTML code behave as a progress bar. <div class=""> <div class="" role="progressbar" style="width:70%"> </div> </div> Start the Exercise

    Bootstrap Pagination

    Basic Pagination

    If you have a web site with lots of pages, you may wish to add some sort of pagination to each page. A basic pagination in Bootstrap looks like this:
  • 1
  • 2
  • 3
  • 4
  • 5
  • To create a basic pagination, add the .pagination class to an <ul> element:

    Example

    <ul class="pagination"> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> </ul> Try it Yourself »

    Active State

    The active state shows what is the current page:
  • 1
  • 2
  • 3
  • 4
  • 5
  • Add class .active to let the user know which page he/she is on:

    Example

    <ul class="pagination"> <li><a href="#">1</a></li> <li class="active"><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> </ul> Try it Yourself »

    Disabled State

    A disabled link cannot be clicked:
  • 1
  • 2
  • 3
  • 4
  • 5
  • Add class .disabled if a link for some reason is disabled:

    Example

    <ul class="pagination"> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li class="disabled"><a href="#">4</a></li> <li><a href="#">5</a></li> </ul> Try it Yourself »

    Pagination Sizing

    Pagination blocks can also be sized to a larger size or a smaller size:
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5
  • Add class .pagination-lg for larger blocks or .pagination-sm for smaller blocks:

    Example

    <ul class="pagination pagination-lg"> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> </ul> <ul class="pagination pagination-sm"> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> </ul> Try it Yourself »

    Breadcrumbs

    Another form for pagination, is breadcrumbs: The .breadcrumb class indicates the current page's location within a navigational hierarchy:

    Example

    <ul class="breadcrumb"> <li><a href="#">Home</a></li> <li><a href="#">Private</a></li> <li><a href="#">Pictures</a></li> <li class="active">Vacation</li> </ul> Try it Yourself »

    Test Yourself With Exercises

    Exercise:

    Add the correct class name to transform the list below into a pagination menu. <ul class=""> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> </ul> Start the Exercise

    Complete Bootstrap Navigation Reference

    For a complete reference of all navigation classes, go to our complete Bootstrap Navigation Reference.

    Bootstrap Pager

    What is Pager?

    Pager is also a form of pagination (as described in the previous chapter). Pager provides previous and next buttons (links). To create previous/next buttons, add the .pager class to an <ul> element:

    Example

    <ul class="pager"> <li><a href="#">Previous</a></li> <li><a href="#">Next</a></li> </ul>

    Result:

    Try it Yourself »

    Align Buttons

    Use the .previous and .next classes to align each button to the sides of the page:

    Example

    <ul class="pager"> <li class="previous"><a href="#">Previous</a></li> <li class="next"><a href="#">Next</a></li> </ul>

    Result:

    Try it Yourself »

    Complete Bootstrap Navigation Reference

    For a complete reference of all navigation classes, go to our complete Bootstrap Navigation Reference.

    Bootstrap List Groups

    Basic List Groups

    The most basic list group is an unordered list with list items:
  • First item
  • Second item
  • Third item
  • To create a basic list group, use an <ul> element with class .list-group, and <li> elements with class .list-group-item:

    Example

    <ul class="list-group"> <li class="list-group-item">First item</li> <li class="list-group-item">Second item</li> <li class="list-group-item">Third item</li> </ul> Try it Yourself »

    List Group With Badges

    You can also add badges to a list group. The badges will automatically be positioned on the right:
  • 12 New
  • 5 Deleted
  • 3 Warnings
  • To create a badge, create a <span> element with class .badge inside the list item:

    Example

    <ul class="list-group"> <li class="list-group-item">New <span class="badge">12</span></li> <li class="list-group-item">Deleted <span class="badge">5</span></li> <li class="list-group-item">Warnings <span class="badge">3</span></li> </ul> Try it Yourself »

    List Group With Linked Items

    The items in a list group can also be hyperlinks. This will add a grey background color on hover: First item Second item Third item To create a list group with linked items, use <div> instead of <ul> and <a> instead of <li>:

    Example

    <div class="list-group"> <a href="#" class="list-group-item">First item</a> <a href="#" class="list-group-item">Second item</a> <a href="#" class="list-group-item">Third item</a> </div> Try it Yourself »

    Active State

    First item Second item Third item Use the .active class to highlight the current item:

    Example

    <div class="list-group"> <a href="#" class="list-group-item active">First item</a> <a href="#" class="list-group-item">Second item</a> <a href="#" class="list-group-item">Third item</a> </div> Try it Yourself »

    Disabled Item

    The following list group has a disabled item: First item Second item Third item To disable an item, add the .disabled class:

    Example

    <div class="list-group"> <a href="#" class="list-group-item disabled">First item</a> <a href="#" class="list-group-item">Second item</a> <a href="#" class="list-group-item">Third item</a> </div> Try it Yourself »

    Contextual Classes

    Contextual classes can be used to color list items:
  • First item
  • Second item
  • Third item
  • Fourth item
  • The classes for coloring list-items are: .list-group-item-success, list-group-item-info, list-group-item-warning, and .list-group-item-danger:

    Example

    <ul class="list-group"> <li class="list-group-item list-group-item-success">First item</li> <li class="list-group-item list-group-item-info">Second item</li> <li class="list-group-item list-group-item-warning">Third item</li> <li class="list-group-item list-group-item-danger">Fourth item</li> </ul> Try it Yourself »

    Custom Content

    You can add nearly any HTML inside a list group item. Bootstrap provides the classes .list-group-item-heading and .list-group-item-text which can be used as follows:

    Example

    <div class="list-group"> <a href="#" class="list-group-item active"> <h4 class="list-group-item-heading">First List Group Item Heading</h4> <p class="list-group-item-text">List Group Item Text</p> </a> <a href="#" class="list-group-item"> <h4 class="list-group-item-heading">Second List Group Item Heading</h4> <p class="list-group-item-text">List Group Item Text</p> </a> <a href="#" class="list-group-item"> <h4 class="list-group-item-heading">Third List Group Item Heading</h4> <p class="list-group-item-text">List Group Item Text</p> </a> </div> Try it Yourself »

    Test Yourself with Exercises!

    Exercise 1 » Exercise 2 » Exercise 3 » Exercise 4 » Exercise 5 »

    Bootstrap Panels

    Panels

    A panel in bootstrap is a bordered box with some padding around its content: A Basic Panel Panels are created with the .panel class, and content inside the panel has a .panel-body class:

    Example

    <div class="panel panel-default"> <div class="panel-body">A Basic Panel</div> </div> Try it Yourself » The .panel-default class is used to style the color of the panel. See the last example on this page for more contextual classes.

    Panel Heading

    Panel Heading Panel Content The .panel-heading class adds a heading to the panel:

    Example

    <div class="panel panel-default"> <div class="panel-heading">Panel Heading</div> <div class="panel-body">Panel Content</div> </div> Try it Yourself »

    Panel Footer

    Panel Content Panel Footer The .panel-footer class adds a footer to the panel:

    Example

    <div class="panel panel-default"> <div class="panel-body">Panel Content</div> <div class="panel-footer">Panel Footer</div> </div> Try it Yourself »

    Panel Group

    To group many panels together, wrap a <div> with class .panel-group around them. The .panel-group class clears the bottom-margin of each panel:

    Example

    <div class="panel-group"> <div class="panel panel-default"> <div class="panel-body">Panel Content</div> </div> <div class="panel panel-default"> <div class="panel-body">Panel Content</div> </div> </div> Try it Yourself »

    Panels with Contextual Classes

    To color the panel, use contextual classes (.panel-default, .panel-primary, .panel-success, .panel-info, .panel-warning, or .panel-danger):

    Example

    Panel with panel-default class Panel Content Panel with panel-primary class Panel Content Panel with panel-success class Panel Content Panel with panel-info class Panel Content Panel with panel-warning class Panel Content Panel with panel-danger class Panel Content Try it Yourself »

    Test Yourself With Exercises

    Exercise:

    Create a basic (default) Bootstrap Panel with the words: "Hello World". <div class=""> <div class="">Hello World</div> </div> Start the Exercise

    Bootstrap Dropdowns

    Basic Dropdown

    A dropdown menu is a toggleable menu that allows the user to choose one value from a predefined list:
  • HTML
  • CSS
  • JavaScript
  • About Us
  • Example

    <div class="dropdown"> <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Dropdown Example <span class="caret"></span></button> <ul class="dropdown-menu"> <li><a href="#">HTML</a></li> <li><a href="#">CSS</a></li> <li><a href="#">JavaScript</a></li> </ul> </div> Try it Yourself »

    Example Explained

    The .dropdown class indicates a dropdown menu. To open the dropdown menu, use a button or a link with a class of .dropdown-toggle and the data-toggle="dropdown" attribute. The .caret class creates a caret arrow icon (), which indicates that the button is a dropdown. Add the .dropdown-menu class to a <ul> element to actually build the dropdown menu.

    Dropdown Divider

    The .divider class is used to separate links inside the dropdown menu with a thin horizontal border:

    Example

    <li class="divider"></li> Try it Yourself »

    Dropdown Header

  • HTML
  • CSS
  • JavaScript
  • About Us
  • The .dropdown-header class is used to add headers inside the dropdown menu:

    Example

    <li class="dropdown-header">Dropdown header 1</li> Try it Yourself »

    Disable and Active items

  • Normal
  • Highlight a specific dropdown item with the .active class (adds a blue background color). To disable an item in the dropdown menu, use the .disabled class (gets a light-grey text color and a "no-parking-sign" icon on hover):

    Example

    <li class="disabled"><a href="#">CSS</a></li> <li class="active"><a href="#">HTML</a></li> Try it Yourself »

    Dropdown Position

  • HTML
  • CSS
  • JavaScript
  • About Us
  • To right-align the dropdown, add the .dropdown-menu-right class to the element with .dropdown-menu:

    Example

    <ul class="dropdown-menu dropdown-menu-right"> Try it Yourself »

    Dropup

  • HTML
  • CSS
  • JavaScript
  • About Us
  • If you want the dropdown menu to expand upwards instead of downwards, change the <div> element with class="dropdown" to "dropup":

    Example

    <div class="dropup"> Try it Yourself »

    Dropdown Accessibility

    To help improve accessibility for people using screen readers, you should include the following role and aria-* attributes, when creating a dropdown menu:

    Example

    <div class="dropdown"> <button class="btn btn-default dropdown-toggle" type="button" id="menu1" data-toggle="dropdown">Tutorials <span class="caret"></span></button> <ul class="dropdown-menu" role="menu" aria-labelledby="menu1"> <li role="presentation"><a role="menuitem" href="#">HTML</a></li> <li role="presentation"><a role="menuitem" href="#">CSS</a></li> <li role="presentation"><a role="menuitem" href="#">JavaScript</a></li> <li role="presentation" class="divider"></li> <li role="presentation"><a role="menuitem" href="#">About Us</a></li> </ul> </div> Try it Yourself »

    Test Yourself With Exercises

    Exercise:

    Add the required classes and attributes to create a dropdown list. <div class=""> <button class="btn btn-primary "> Dropdown Example <span class="caret"></span></button> <ul class=""> <li><a href="#">HTML</a></li> <li><a href="#">CSS</a></li> <li><a href="#">JavaScript</a></li> </ul> </div> Start the Exercise

    Complete Bootstrap Dropdown Reference

    For a complete reference of all dropdown options, methods and events, go to our Bootstrap JS Dropdown Reference.

    Bootstrap Collapse

    Basic Collapsible

    Collapsibles are useful when you want to hide and show large amount of content: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

    Example

    <button data-toggle="collapse" data-target="#demo">Collapsible</button> <div id="demo" class="collapse"> Lorem ipsum dolor text.... </div> Try it Yourself »

    Example Explained

    The .collapse class indicates a collapsible element (a <div> in our example); this is the content that will be shown or hidden with a click of a button. To control (show/hide) the collapsible content, add the data-toggle="collapse" attribute to an <a> or a <button> element. Then add the data-target="#id" attribute to connect the button with the collapsible content (<div id="demo">). Note: For <a> elements, you can use the href attribute instead of the data-target attribute:

    Example

    <a href="#demo" data-toggle="collapse">Collapsible</a> <div id="demo" class="collapse"> Lorem ipsum dolor text.... </div> Try it Yourself » By default, the collapsible content is hidden. However, you can add the .in class to show the content by default:

    Example

    <div id="demo" class="collapse in"> Lorem ipsum dolor text.... </div> Try it Yourself »

    Collapsible Panel

    Collapsible panel

    Panel Body Panel Footer The following example shows a collapsible panel:

    Example

    <div class="panel-group"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#collapse1">Collapsible panel</a> </h4> </div> <div id="collapse1" class="panel-collapse collapse"> <div class="panel-body">Panel Body</div> <div class="panel-footer">Panel Footer</div> </div> </div> </div> Try it Yourself »

    Collapsible List Group

    Collapsible list group

  • One
  • Two
  • Three
  • Footer The following shows a collapsible panel with a list group inside:

    Example

    <div class="panel-group"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#collapse1">Collapsible list group</a> </h4> </div> <div id="collapse1" class="panel-collapse collapse"> <ul class="list-group"> <li class="list-group-item">One</li> <li class="list-group-item">Two</li> <li class="list-group-item">Three</li> </ul> <div class="panel-footer">Footer</div> </div> </div> </div> Try it Yourself »

    Accordion

    Collapsible Group 1

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

    Collapsible Group 2

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

    Collapsible Group 3

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. The following example shows a simple accordion by extending the panel component. Note: Use the data-parent attribute to make sure that all collapsible elements under the specified parent will be closed when one of the collapsible item is shown.

    Example

    <div class="panel-group" id="accordion"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapse1"> Collapsible Group 1</a> </h4> </div> <div id="collapse1" class="panel-collapse collapse in"> <div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapse2"> Collapsible Group 2</a> </h4> </div> <div id="collapse2" class="panel-collapse collapse"> <div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapse3"> Collapsible Group 3</a> </h4> </div> <div id="collapse3" class="panel-collapse collapse"> <div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div> </div> </div> </div> Try it Yourself »

    Complete Bootstrap Collapse Reference

    For a complete reference of all collapse options, methods and events, go to our Bootstrap JS Collapse Reference.

    Bootstrap Tabs and Pills

    Menus

    Most web pages have some kind of a menu. In HTML, a menu is often defined in an unordered list <ul> (and styled afterwards), like this: <ul> <li><a href="#">Home</a></li> <li><a href="#">Menu 1</a></li> <li><a href="#">Menu 2</a></li> <li><a href="#">Menu 3</a></li> </ul> If you want to create a horizontal menu of the list above, add the .list-inline class to <ul>: <ul class="list-inline"> Try it Yourself » Or you can display the menu above with Bootstraps' Tabs and Pills (see below). Note: See the last example on this page to find out how to make tabs and pills toggleable/dynamic.

    Tabs

  • Home
  • Menu 1
  • Menu 2
  • Menu 3
  • Tabs are created with <ul class="nav nav-tabs">: Tip: Also mark the current page with <li class="active">. The following example creates navigation tabs:

    Example

    <ul class="nav nav-tabs"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Menu 1</a></li> <li><a href="#">Menu 2</a></li> <li><a href="#">Menu 3</a></li> </ul> Try it Yourself »

    Tabs With Dropdown Menu

  • Home
  • Submenu 1-1
  • Submenu 1-2
  • Submenu 1-3
  • Menu 2
  • Menu 3
  • Tabs can also hold dropdown menus. The following example adds a dropdown menu to "Menu 1":

    Example

    <ul class="nav nav-tabs"> <li class="active"><a href="#">Home</a></li> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">Menu 1 <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="#">Submenu 1-1</a></li> <li><a href="#">Submenu 1-2</a></li> <li><a href="#">Submenu 1-3</a></li> </ul> </li> <li><a href="#">Menu 2</a></li> <li><a href="#">Menu 3</a></li> </ul> Try it Yourself »

    Pills

  • Home
  • Menu 1
  • Menu 2
  • Menu 3
  • Pills are created with <ul class="nav nav-pills">. Also mark the current page with <li class="active">:

    Example

    <ul class="nav nav-pills"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Menu 1</a></li> <li><a href="#">Menu 2</a></li> <li><a href="#">Menu 3</a></li> </ul> Try it Yourself »

    Vertical Pills

  • Home
  • Menu 1
  • Menu 2
  • Menu 3
  • Pills can also be displayed vertically. Just add the .nav-stacked class:

    Example

    <ul class="nav nav-pills nav-stacked"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Menu 1</a></li> <li><a href="#">Menu 2</a></li> <li><a href="#">Menu 3</a></li> </ul> Try it Yourself »

    Vertical Pills in a Row

    Text... Text... Text...
  • Home
  • Menu 1
  • Menu 2
  • Menu 3
  • The following example places the vertical pill menu inside the last column. So, on a large screen the menu will be displayed to the right. But on a small screen, the content will automatically adjust itself into a single-column layout:

    Example

    <div class="col-md-3"> <ul class="nav nav-pills nav-stacked"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Menu 1</a></li> <li><a href="#">Menu 2</a></li> <li><a href="#">Menu 3</a></li> </ul> </div> Try it Yourself »

    Pills With Dropdown Menu

  • Home
  • Submenu 1-1
  • Submenu 1-2
  • Submenu 1-3
  • Menu 2
  • Menu 3
  • Pills can also hold dropdown menus. The following example adds a dropdown menu to "Menu 1":

    Example

    <ul class="nav nav-pills nav-stacked"> <li class="active"><a href="#">Home</a></li> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">Menu 1 <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="#">Submenu 1-1</a></li> <li><a href="#">Submenu 1-2</a></li> <li><a href="#">Submenu 1-3</a></li> </ul> </li> <li><a href="#">Menu 2</a></li> <li><a href="#">Menu 3</a></li> </ul> Try it Yourself »

    Centered Tabs and Pills

  • Home
  • Menu 1
  • Menu 2
  • Menu 3
  • To center/justify the tabs and pills, use the .nav-justified class. Note that on screens that are smaller than 768px, the list items are stacked (content will remain centered):

    Example

    <!-- Centered Tabs --> <ul class="nav nav-tabs nav-justified"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Menu 1</a></li> <li><a href="#">Menu 2</a></li> <li><a href="#">Menu 3</a></li> </ul> <!-- Centered Pills --> <ul class="nav nav-pills nav-justified"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Menu 1</a></li> <li><a href="#">Menu 2</a></li> <li><a href="#">Menu 3</a></li> </ul> Try it Yourself »

    Toggleable / Dynamic Tabs

  • Home
  • Menu 1
  • Menu 2
  • Menu 3
  • HOME

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

    Menu 1

    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

    Menu 2

    Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam.

    Menu 3

    Eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. To make the tabs toggleable, add the data-toggle="tab" attribute to each link. Then add a .tab-pane class with a unique ID for every tab and wrap them inside a <div> element with class .tab-content. If you want the tabs to fade in and out when clicking on them, add the .fade class to .tab-pane:

    Example

    <ul class="nav nav-tabs"> <li class="active"><a data-toggle="tab" href="#home">Home</a></li> <li><a data-toggle="tab" href="#menu1">Menu 1</a></li> <li><a data-toggle="tab" href="#menu2">Menu 2</a></li> </ul> <div class="tab-content"> <div id="home" class="tab-pane fade in active"> <h3>HOME</h3> <p>Some content.</p> </div> <div id="menu1" class="tab-pane fade"> <h3>Menu 1</h3> <p>Some content in menu 1.</p> </div> <div id="menu2" class="tab-pane fade"> <h3>Menu 2</h3> <p>Some content in menu 2.</p> </div> </div> Try it Yourself »

    Toggleable / Dynamic Pills

    The same code applies to pills; only change the data-toggle attribute to data-toggle="pill":

    Example

    <ul class="nav nav-pills"> <li class="active"><a data-toggle="pill" href="#home">Home</a></li> <li><a data-toggle="pill" href="#menu1">Menu 1</a></li> <li><a data-toggle="pill" href="#menu2">Menu 2</a></li> </ul> <div class="tab-content"> <div id="home" class="tab-pane fade in active"> <h3>HOME</h3> <p>Some content.</p> </div> <div id="menu1" class="tab-pane fade"> <h3>Menu 1</h3> <p>Some content in menu 1.</p> </div> <div id="menu2" class="tab-pane fade"> <h3>Menu 2</h3> <p>Some content in menu 2.</p> </div> </div> Try it Yourself »

    Test Yourself With Exercises

    Exercise:

    Add the required class to create a Tab Menu. <ul class=""> <li><a href="#">Home</a></li> <li><a href="#">HTML</a></li> <li><a href="#">CSS</a></li> <li><a href="#">JavaScript</a></li> </ul> Start the Exercise

    Complete Bootstrap Navigation Reference

    For a complete reference of all navigation classes, go to our complete Bootstrap Navigation Reference. For a complete reference of all tab options, methods and events, go to our Bootstrap JS Tab Reference.

    Bootstrap Navigation Bar

    Navigation Bars

    A navigation bar is a navigation header that is placed at the top of the page: With Bootstrap, a navigation bar can extend or collapse, depending on the screen size. A standard navigation bar is created with <nav class="navbar navbar-default">. The following example shows how to add a navigation bar to the top of the page:

    Example

    <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a> </div> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Page 1</a></li> <li><a href="#">Page 2</a></li> <li><a href="#">Page 3</a></li> </ul> </div> </nav> ... Try it Yourself » Note: All of the examples on this page will show a navigation bar that takes up too much space on small screens (however, the navigation bar will be on one single line on large screens - because Bootstrap is responsive). This problem (with the small screens) will be solved in the last example on this page.

    Inverted Navigation Bar

    If you don't like the style of the default navigation bar, Bootstrap provides an alternative, black navbar: Just change the .navbar-default class into .navbar-inverse:

    Example

    <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a> </div> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Page 1</a></li> <li><a href="#">Page 2</a></li> <li><a href="#">Page 3</a></li> </ul> </div> </nav> Try it Yourself »

    Navigation Bar With Dropdown

    Navigation bars can also hold dropdown menus. The following example adds a dropdown menu for the "Page 1" button:

    Example

    <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a> </div> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="#">Page 1-1</a></li> <li><a href="#">Page 1-2</a></li> <li><a href="#">Page 1-3</a></li> </ul> </li> <li><a href="#">Page 2</a></li> <li><a href="#">Page 3</a></li> </ul> </div> </nav> Try it Yourself »

    Right-Aligned Navigation Bar

    The .navbar-right class is used to right-align navigation bar buttons. In the following example we insert a "Sign Up" button and a "Login" button to the right in the navigation bar. We also add a glyphicon on each of the two new buttons:

    Example

    <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a> </div> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Page 1</a></li> <li><a href="#">Page 2</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li> <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li> </ul> </div> </nav> Try it Yourself »

    Navbar Buttons

    To add buttons inside the navbar, add the .navbar-btn class on a Bootstrap button:

    Example

    <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a> </div> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> </ul> <button class="btn btn-danger navbar-btn">Button</button> </div> </nav> Try it Yourself »

    Navbar Forms

    To add form elements inside the navbar, add the .navbar-form class to a form element and add an input(s). Note that we have added a .form-group class to the div container holding the input. This adds proper padding if you have more than one inputs (you will learn more about this in the Forms chapter).

    Example

    <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a> </div> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Page 1</a></li> <li><a href="#">Page 2</a></li> </ul> <form class="navbar-form navbar-left" action="/action_page.php"> <div class="form-group"> <input type="text" class="form-control" placeholder="Search"> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> </nav> Try it Yourself » You can also use the .input-group and .input-group-addon classes to attach an icon or help text next to the input field. You will learn more about these classes in the Bootstrap Inputs chapter.

    Example

    <form class="navbar-form navbar-left" action="/action_page.php"> <div class="input-group"> <input type="text" class="form-control" placeholder="Search"> <div class="input-group-btn"> <button class="btn btn-default" type="submit"> <i class="glyphicon glyphicon-search"></i> </button> </div> </div> </form> Try it Yourself »

    Navbar Text

    Use the .navbar-text class to vertical align any elements inside the navbar that are not links (ensures proper padding and text color).

    Example

    <nav class="navbar navbar-inverse"> <ul class="nav navbar-nav"> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> </ul> <p class="navbar-text">Some text</p> </nav> Try it Yourself »

    Fixed Navigation Bar

    The navigation bar can also be fixed at the top or at the bottom of the page. A fixed navigation bar stays visible in a fixed position (top or bottom) independent of the page scroll. The .navbar-fixed-top class makes the navigation bar fixed at the top:

    Example

    <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a> </div> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Page 1</a></li> <li><a href="#">Page 2</a></li> <li><a href="#">Page 3</a></li> </ul> </div> </nav> Try it Yourself » The .navbar-fixed-bottom class makes the navigation bar stay at the bottom:

    Example

    <nav class="navbar navbar-inverse navbar-fixed-bottom"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a> </div> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Page 1</a></li> <li><a href="#">Page 2</a></li> <li><a href="#">Page 3</a></li> </ul> </div> </nav> Try it Yourself »

    Collapsing The Navigation Bar

    The navigation bar often takes up too much space on a small screen. We should hide the navigation bar; and only show it when it is needed. In the following example the navigation bar is replaced by a button in the top right corner. Only when the button is clicked, the navigation bar will be displayed:

    Example

    <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">WebSiteName</a> </div> <div class="collapse navbar-collapse" id="myNavbar"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Page 1</a></li> <li><a href="#">Page 2</a></li> <li><a href="#">Page 3</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li> <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li> </ul> </div> </div> </nav> Try it Yourself »

    Test Yourself With Exercises

    Exercise:

    Add the required class names to create a default Navigation Bar. <nav class=""> <div class="container-fluid"> <ul class="nav navbar-nav"> <li><a href="#">Page 1</a></li> <li><a href="#">Page 2</a></li> <li><a href="#">Page 3</a></li> </ul> </div> </nav> Start the Exercise

    Bootstrap Forms

    Bootstrap's Default Settings

    Form controls automatically receive some global styling with Bootstrap: All textual <input>, <textarea>, and <select> elements with class .form-control have a width of 100%.

    Bootstrap Form Layouts

    Bootstrap provides three types of form layouts:
  • Vertical form (this is default)
  • Horizontal form
  • Inline form
  • Standard rules for all three form layouts:
  • Wrap labels and form controls in <div class="form-group"> (needed for optimum spacing)
  • Add class .form-control to all textual <input>, <textarea>, and <select> elements
  • Bootstrap Vertical Form (default)

    The following example creates a vertical form with two input fields, one checkbox, and a submit button:

    Example

    <form action="/action_page.php"> <div class="form-group"> <label for="email">Email address:</label> <input type="email" class="form-control" id="email"> </div> <div class="form-group"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd"> </div> <div class="checkbox"> <label><input type="checkbox"> Remember me</label> </div> <button type="submit" class="btn btn-default">Submit</button> </form> Try it Yourself »

    Bootstrap Inline Form

    In an inline form, all of the elements are inline, left-aligned, and the labels are alongside. Note: This only applies to forms within viewports that are at least 768px wide! Additional rule for an inline form:
  • Add class .form-inline to the <form> element
  • The following example creates an inline form with two input fields, one checkbox, and one submit button:

    Example

    <form class="form-inline" action="/action_page.php"> <div class="form-group"> <label for="email">Email address:</label> <input type="email" class="form-control" id="email"> </div> <div class="form-group"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd"> </div> <div class="checkbox"> <label><input type="checkbox"> Remember me</label> </div> <button type="submit" class="btn btn-default">Submit</button> </form> Try it Yourself » Tip: If you don't include a label for every input, screen readers will have trouble with your forms. You can hide the labels for all devices, except screen readers, by using the .sr-only class:

    Example

    <form class="form-inline" action="/action_page.php"> <div class="form-group"> <label class="sr-only" for="email">Email address:</label> <input type="email" class="form-control" id="email"> </div> <div class="form-group"> <label class="sr-only" for="pwd">Password:</label> <input type="password" class="form-control" id="pwd"> </div> <div class="checkbox"> <label><input type="checkbox"> Remember me</label> </div> <button type="submit" class="btn btn-default">Submit</button> </form> Try it Yourself »

    Bootstrap Horizontal Form

    A horizontal form means that the labels are aligned next to the input field (horizontal) on large and medium screens. On small screens (767px and below), it will transform to a vertical form (labels are placed on top of each input). Additional rules for a horizontal form:
  • Add class .form-horizontal to the <form> element
  • Add class .control-label to all <label> elements
  • Tip: Use Bootstrap's predefined grid classes to align labels and groups of form controls in a horizontal layout. The following example creates a horizontal form with two input fields, one checkbox, and one submit button.

    Example

    <form class="form-horizontal" action="/action_page.php"> <div class="form-group"> <label class="control-label col-sm-2" for="email">Email:</label> <div class="col-sm-10"> <input type="email" class="form-control" id="email" placeholder="Enter email"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="pwd">Password:</label> <div class="col-sm-10"> <input type="password" class="form-control" id="pwd" placeholder="Enter password"> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <div class="checkbox"> <label><input type="checkbox"> 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">Submit</button> </div> </div> </form> Try it Yourself »

    Bootstrap Form Inputs

    Supported Form Controls

    Bootstrap supports the following form controls:
  • input
  • textarea
  • checkbox
  • radio
  • select
  • Bootstrap Input

    Bootstrap supports all the HTML5 input types: text, password, datetime, datetime-local, date, month, time, week, number, email, url, search, tel, and color. Note: Inputs will NOT be fully styled if their type is not properly declared! The following example contains two input elements; one of type text and one of type password:

    Example

    <div class="form-group"> <label for="usr">Name:</label> <input type="text" class="form-control" id="usr"> </div> <div class="form-group"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd"> </div> Try it Yourself »

    Bootstrap Textarea

    The following example contains a textarea:

    Example

    <div class="form-group"> <label for="comment">Comment:</label> <textarea class="form-control" rows="5" id="comment"></textarea> </div> Try it Yourself »

    Bootstrap Checkboxes

    Checkboxes are used if you want the user to select any number of options from a list of preset options. The following example contains three checkboxes. The last option is disabled:

    Example

    <div class="checkbox"> <label><input type="checkbox" value=">Option 1</label> </div> <div class="checkbox"> <label><input type="checkbox" value=">Option 2</label> </div> <div class="checkbox disabled"> <label><input type="checkbox" value=" disabled>Option 3</label> </div> Try it Yourself » Use the .checkbox-inline class if you want the checkboxes to appear on the same line:

    Example

    <label class="checkbox-inline"><input type="checkbox" value=">Option 1</label> <label class="checkbox-inline"><input type="checkbox" value=">Option 2</label> <label class="checkbox-inline"><input type="checkbox" value=">Option 3</label> Try it Yourself »

    Bootstrap Radio Buttons

    Radio buttons are used if you want to limit the user to just one selection from a list of preset options. The following example contains three radio buttons. The first option is checked by default and the last option is disabled:

    Example

    <div class="radio"> <label><input type="radio" name="optradio" checked>Option 1</label> </div> <div class="radio"> <label><input type="radio" name="optradio">Option 2</label> </div> <div class="radio disabled"> <label><input type="radio" name="optradio" disabled>Option 3</label> </div> Try it Yourself » Use the .radio-inline class if you want the radio buttons to appear on the same line:

    Example

    <label class="radio-inline"><input type="radio" name="optradio" checked>Option 1</label> <label class="radio-inline"><input type="radio" name="optradio">Option 2</label> <label class="radio-inline"><input type="radio" name="optradio">Option 3</label> Try it Yourself »

    Bootstrap Select List

    Select lists are used if you want to allow the user to pick from multiple options. The following example contains a dropdown list (select list):

    Example

    <div class="form-group"> <label for="sel1">Select list:</label> <select class="form-control" id="sel1"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select> </div> Try it Yourself »

    Bootstrap Form Inputs (more)

    Static Control

    If you need to insert plain text next to a form label within a horizontal form, use the .form-control-static class on a <p> element:

    Example

    <form class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2">Email:</label> <div class="col-sm-10"> <p class="form-control-static">someone@example.com</p> </div> </div> </form> Try it Yourself »

    Bootstrap Input Groups

    The .input-group class is a container to enhance an input by adding an icon, text or a button in front or behind it as a "help text". The .input-group-addon class attaches an icon or help text next to the input field. Text

    Example

    <form> <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span> <input id="email" type="text" class="form-control" name="email" placeholder="Email"> </div> <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span> <input id="password" type="password" class="form-control" name="password" placeholder="Password"> </div> <div class="input-group"> <span class="input-group-addon">Text</span> <input id="msg" type="text" class="form-control" name="msg" placeholder="Additional Info"> </div> </form> Try it Yourself » The .input-group-btn attaches a button next to an input. This is often used together with a search bar:

    Example

    <form> <div class="input-group"> <input type="text" class="form-control" placeholder="Search"> <div class="input-group-btn"> <button class="btn btn-default" type="submit"> <i class="glyphicon glyphicon-search"></i> </button> </div> </div> </form> Try it Yourself »

    Bootstrap Form Control States

  • INPUT FOCUS - The outline of the input is removed and a box-shadow is applied on focus
  • DISABLED INPUTS - Add a disabled attribute to disable an input field
  • DISABLED FIELDSETS - Add a disabled attribute to a fieldset to disable all controls within
  • READONLY INPUTS - Add a readonly attribute to an input to prevent user input
  • VALIDATION STATES - Bootstrap includes validation styles for error, warning, and success messages. To use, add .has-warning, .has-error, or .has-success to the parent element
  • ICONS - You can add feedback icons with the .has-feedback class and an icon
  • HIDDEN LABELS - Add a .sr-only class on non-visible labels
  • The following example demonstrates some of the form control states above in a Horizontal form:

    Example

    <form class="form-horizontal"> <div class="form-group"> <label class="col-sm-2 control-label">Focused</label> <div class="col-sm-10"> <input class="form-control" id="focusedInput" type="text" value="Click to focus"> </div> </div> <div class="form-group"> <label for="disabledInput" class="col-sm-2 control-label">Disabled</label> <div class="col-sm-10"> <input class="form-control" id="disabledInput" type="text" disabled> </div> </div> <fieldset disabled> <div class="form-group"> <label for="disabledTextInput" class="col-sm-2 control-label">Fieldset disabled</label> <div class="col-sm-10"> <input type="text" id="disabledTextInput" class="form-control"> </div> </div> <div class="form-group"> <label for="disabledSelect" class="col-sm-2 control-label"></label> <div class="col-sm-10"> <select id="disabledSelect" class="form-control"> <option>Disabled select</option> </select> </div> </div> </fieldset> <div class="form-group has-success has-feedback"> <label class="col-sm-2 control-label" for="inputSuccess"> Input with success and icon</label> <div class="col-sm-10"> <input type="text" class="form-control" id="inputSuccess"> <span class="glyphicon glyphicon-ok form-control-feedback"></span> </div> </div> <div class="form-group has-warning has-feedback"> <label class="col-sm-2 control-label" for="inputWarning"> Input with warning and icon</label> <div class="col-sm-10"> <input type="text" class="form-control" id="inputWarning"> <span class="glyphicon glyphicon-warning-sign form-control-feedback"></span> </div> </div> <div class="form-group has-error has-feedback"> <label class="col-sm-2 control-label" for="inputError"> Input with error and icon</label> <div class="col-sm-10"> <input type="text" class="form-control" id="inputError"> <span class="glyphicon glyphicon-remove form-control-feedback"></span> </div> </div> </form> Try it Yourself » And here is an example of some of the form control states in an Inline form:

    Example

    <form class="form-inline"> <div class="form-group"> <label for="focusedInput">Focused</label> <input class="form-control" id="focusedInput" type="text"> </div> <div class="form-group"> <label for="inputPassword">Disabled</label> <input class="form-control" id="disabledInput" type="text" disabled> </div> <div class="form-group has-success has-feedback"> <label for="inputSuccess2">Input with success</label> <input type="text" class="form-control" id="inputSuccess2"> <span class="glyphicon glyphicon-ok form-control-feedback"></span> </div> <div class="form-group has-warning has-feedback"> <label for="inputWarning2">Input with warning</label> <input type="text" class="form-control" id="inputWarning2"> <span class="glyphicon glyphicon-warning-sign form-control-feedback"></span> </div> <div class="form-group has-error has-feedback"> <label for="inputError2">Input with error</label> <input type="text" class="form-control" id="inputError2"> <span class="glyphicon glyphicon-remove form-control-feedback"></span> </div> </form> Try it Yourself »

    Bootstrap Input Sizing

    Input Sizing in Forms

    Set the heights of input elements using classes like .input-lg and .input-sm. Set the widths of elements using grid column classes like .col-lg-*and .col-sm-*.

    Height Sizing

    The following examples shows input elements with different heights:

    Example

    <form> <div class="form-group"> <label for="inputsm">Small input</label> <input class="form-control input-sm" id="inputsm" type="text"> </div> <div class="form-group"> <label for="inputdefault">Default input</label> <input class="form-control" id="inputdefault" type="text"> </div> <div class="form-group"> <label for="inputlg">Large input</label> <input class="form-control input-lg" id="inputlg" type="text"> </div> </form> Try it Yourself » You can quickly size labels and form controls within a Horizontal form by adding .form-group-* to the <div class="form-group"> element:

    Example

    <div class="form-group form-group-lg"> Try it Yourself » You can also quickly size all inputs and other elements inside an .input-group with the .input-group-sm or .input-group-lg classes:

    Example

    <div class="input-group input-group-lg"> Try it Yourself » The following examples shows input elements with different widths using different .col-xs-* classes:

    Example

    <div class="form-group row"> <div class="col-xs-2"> <label for="ex1">col-xs-2</label> <input class="form-control" id="ex1" type="text"> </div> <div class="col-xs-3"> <label for="ex2">col-xs-3</label> <input class="form-control" id="ex2" type="text"> </div> <div class="col-xs-4"> <label for="ex3">col-xs-4</label> <input class="form-control" id="ex3" type="text"> </div> </div> Try it Yourself »

    Help Text

    Use the .help-block class to add a block level help text in forms:

    Example

    <div class="form-group"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd" placeholder="Enter password"> <span class="help-block">This is some help text...</span> </div> Try it Yourself »

    Bootstrap Media Objects

    Media Objects

    Bootstrap provides an easy way to align media objects (like images or videos) to the left or to the right of some content. This can be used to display blog comments, tweets and so on: Demo Avatar John Doe

    John Doe Posted on February 19, 2016

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Demo Avatar Jane Doe

    Jane Doe Posted on February 20, 2016

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

    Alicia Keyes Posted on February 25, 2016

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nulla vel metus scelerisque ante sollicitudin commodo. Demo Avatar Alicia Keyes

    Basic Media Object

    Demo Avatar John Doe Blank

    John Doe

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

    John Doe

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Demo Avatar John Doe Blank

    Example

    <!-- Left-aligned --> <div class="media"> <div class="media-left"> <img src="img_avatar1.png" class="media-object" style="width:60px"> </div> <div class="media-body"> <h4 class="media-heading">John Doe</h4> <p>Lorem ipsum...</p> </div> </div> <!-- Right-aligned --> <div class="media"> <div class="media-body"> <h4 class="media-heading">John Doe</h4> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> </div> <div class="media-right"> <img src="img_avatar1.png" class="media-object" style="width:60px"> </div> </div> Try it Yourself »

    Example explained

    Use a <div> element with the .media class to create a container for media objects. Use the .media-left class to align the media object (image) to the left, or the .media-right class to align it to the right. Text that should appear next to the image, is placed inside a container with class="media-body". Additionally, you can use .media-heading for headings.

    Top, Middle or Bottom Alignment

    The media object can also be top, middle or bottom aligned with the media-top, media-middle or media-bottom class: Demo Avatar John Doe Blank

    Media Top

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Demo Avatar John Doe Blank

    Media Middle

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Demo Avatar John Doe Blank

    Media Bottom

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

    Example

    <!-- Media top --> <div class="media"> <div class="media-left media-top"> <img src="img_avatar1.png" class="media-object" style="width:60px"> </div> <div class="media-body"> <h4 class="media-heading">Media Top</h4> <p>Lorem ipsum...</p> </div> </div> <!-- Media middle --> <div class="media"> <div class="media-left media-middle"> <img src="img_avatar1.png" class="media-object" style="width:60px"> </div> <div class="media-body"> <h4 class="media-heading">Media Middle</h4> <p>Lorem ipsum...</p> </div> </div> <!-- Media bottom --> <div class="media"> <div class="media-left media-bottom"> <img src="img_avatar1.png" class="media-object" style="width:60px"> </div> <div class="media-body"> <h4 class="media-heading">Media Bottom</h4> <p>Lorem ipsum...</p> </div> </div> Try it Yourself »

    Nesting Media Objects

    Media objects can also be nested (a media object inside a media object):

    Example

    Demo Avatar John Doe Blank

    John Doe Posted on February 19, 2016

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Demo Avatar John Doe Green

    John Doe Posted on February 20, 2016

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Demo Avatar John Doe Blue

    John Doe Posted on February 21, 2016

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Try it Yourself »

    Another Example of Nesting

    Example

    Demo Avatar John Doe Blank

    John Doe Posted on February 19, 2016

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Demo Avatar John Doe Green

    John Doe Posted on February 20, 2016

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Demo Avatar John Doe Blue

    John Doe Posted on February 21, 2016

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Demo Avatar Jane Doe Green

    Jane Doe Posted on February 20, 2016

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Demo Avatar Jane Doe Red

    Jane Doe Posted on February 19, 2016

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Try it Yourself »

    Bootstrap Carousel Plugin

    The Carousel Plugin

    The Carousel plugin is a component for cycling through elements, like a carousel (slideshow). Tip: Plugins can be included individually (using Bootstrap's individual "carousel.js" file), or all at once (using "bootstrap.js" or "bootstrap.min.js").

    Carousel Example

    Los Angeles

    LA is always so much fun!

    Chicago

    Thank you, Chicago!

    New York

    We love the Big Apple! Previous Next Note: Carousels are not supported properly in Internet Explorer 9 and earlier (because they use CSS3 transitions and animations to achieve the slide effect). The following example shows how to create a basic carousel:

    Example

    <div id="myCarousel" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#myCarousel" data-slide-to="0" class="active"></li> <li data-target="#myCarousel" data-slide-to="1"></li> <li data-target="#myCarousel" data-slide-to="2"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner"> <div class="item active"> <img src="la.jpg" alt="Los Angeles"> </div> <div class="item"> <img src="chicago.jpg" alt="Chicago"> </div> <div class="item"> <img src="ny.jpg" alt="New York"> </div> </div> <!-- Left and right controls --> <a class="left carousel-control" href="#myCarousel" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#myCarousel" data-slide="next"> <span class="glyphicon glyphicon-chevron-right"></span> <span class="sr-only">Next</span> </a> </div> Try it Yourself »

    Example Explained

    The outermost <div>: Carousels require the use of an id (in this case id="myCarousel") for carousel controls to function properly. The class="carousel" specifies that this <div> contains a carousel.The .slide class adds a CSS transition and animation effect, which makes the items slide when showing a new item. Omit this class if you do not want this effect.The data-ride="carousel" attribute tells Bootstrap to begin animating the carousel immediately when the page loads. The "Indicators" part: The indicators are the little dots at the bottom of each slide (which indicates how many slides there are in the carousel, and which slide the user is currently viewing). The indicators are specified in an ordered list with class .carousel-indicators. The data-target attribute points to the id of the carousel. The data-slide-to attribute specifies which slide to go to, when clicking on the specific dot. The "Wrapper for slides" part: The slides are specified in a <div> with class .carousel-inner. The content of each slide is defined in a <div> with class .item. This can be text or images. The .active class needs to be added to one of the slides. Otherwise, the carousel will not be visible. The "Left and right controls" part: This code adds "left" and "right" buttons that allows the user to go back and forth between the slides manually. The data-slide attribute accepts the keywords "prev" or "next", which alters the slide position relative to its current position.

    Add Captions to Slides

    Add <div class="carousel-caption"> within each <div class="item"> to create a caption for each slide:

    Example

    <div id="myCarousel" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#myCarousel" data-slide-to="0" class="active"></li> <li data-target="#myCarousel" data-slide-to="1"></li> <li data-target="#myCarousel" data-slide-to="2"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner"> <div class="item active"> <img src="la.jpg" alt="Chania"> <div class="carousel-caption"> <h3>Los Angeles</h3> <p>LA is always so much fun!</p> </div> </div> <div class="item"> <img src="chicago.jpg" alt="Chicago"> <div class="carousel-caption"> <h3>Chicago</h3> <p>Thank you, Chicago!</p> </div> </div> <div class="item"> <img src="ny.jpg" alt="New York"> <div class="carousel-caption"> <h3>New York</h3> <p>We love the Big Apple!</p> </div> </div> </div> <!-- Left and right controls --> <a class="left carousel-control" href="#myCarousel" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#myCarousel" data-slide="next"> <span class="glyphicon glyphicon-chevron-right"></span> <span class="sr-only">Next</span> </a> </div> Try it Yourself »

    Complete Bootstrap Carousel Reference

    For a complete reference of all carousel options, methods and events, go to our Bootstrap JS Carousel Reference.

    Bootstrap Modal Plugin

    The Modal Plugin

    The Modal plugin is a dialog box/popup window that is displayed on top of the current page: Some text in the modal. Tip: Plugins can be included individually (using Bootstrap's individual "modal.js" file), or all at once (using "bootstrap.js" or "bootstrap.min.js").

    How To Create a Modal

    The following example shows how to create a basic modal:

    Example

    <!-- Trigger the modal with a button --> <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button> <!-- Modal --> <div id="myModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Modal Header</h4> </div> <div class="modal-body"> <p>Some text in the modal.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> Try it Yourself »

    Example Explained

    The "Trigger" part: To trigger the modal window, you need to use a button or a link. Then include the two data-* attributes:
  • data-toggle="modal" opens the modal window
  • data-target="#myModal" points to the id of the modal
  • The "Modal" part: The parent <div> of the modal must have an ID that is the same as the value of the data-target attribute used to trigger the modal ("myModal"). The .modal class identifies the content of <div> as a modal and brings focus to it. The .fade class adds a transition effect which fades the modal in and out. Remove this class if you do not want this effect. The attribute role="dialog" improves accessibility for people using screen readers. The .modal-dialog class sets the proper width and margin of the modal. The "Modal content" part: The <div> with class="modal-content" styles the modal (border, background-color, etc.). Inside this <div>, add the modal's header, body, and footer. The .modal-header class is used to define the style for the header of the modal. The <button> inside the header has a data-dismiss="modal" attribute which closes the modal if you click on it. The .close class styles the close button, and the .modal-title class styles the header with a proper line-height. The .modal-body class is used to define the style for the body of the modal. Add any HTML markup here; paragraphs, images, videos, etc. The .modal-footer class is used to define the style for the footer of the modal. Note that this area is right aligned by default.

    Modal Size

    Change the size of the modal by adding the .modal-sm class for small modals or .modal-lg class for large modals. Add the size class to the <div> element with class .modal-dialog:

    Small Modal

    <div class="modal-dialog modal-sm"> Try it Yourself »

    Large Modal

    <div class="modal-dialog modal-lg"> Try it Yourself » By default, modals are medium in size.

    Complete Bootstrap Modal Reference

    For a complete reference of all modal options, methods and events, go to our Bootstrap JS Modal Reference.

    Bootstrap Tooltip Plugin

    The Tooltip Plugin

    The Tooltip plugin is small pop-up box that appears when the user moves the mouse pointer over an element: Hover over me Tip: Plugins can be included individually (using Bootstrap's individual "tooltip.js" file), or all at once (using "bootstrap.js" or "bootstrap.min.js").

    How To Create a Tooltip

    To create a tooltip, add the data-toggle="tooltip" attribute to an element. Use the title attribute to specify the text that should be displayed inside the tooltip: <a href="#" data-toggle="tooltip" title="Hooray!">Hover over me</a> Note: Tooltips must be initialized with jQuery: select the specified element and call the tooltip() method. The following code will enable all tooltips in the document:

    Example

    <script> $(document).ready(function(){ $('[data-toggle="tooltip"]').tooltip(); }); </script> Try it Yourself »

    Positioning Tooltips

    By default, the tooltip will appear on top of the element. Use the data-placement attribute to set the position of the tooltip on top, bottom, left or the right side of the element:

    Example

    <a href="#" data-toggle="tooltip" data-placement="top" title="Hooray!">Hover</a> <a href="#" data-toggle="tooltip" data-placement="bottom" title="Hooray!">Hover</a> <a href="#" data-toggle="tooltip" data-placement="left" title="Hooray!">Hover</a> <a href="#" data-toggle="tooltip" data-placement="right" title="Hooray!">Hover</a> Try it Yourself » Tip: You can also use the data-placement attribute with a value of "auto", which will let the browser decide the position of the tooltip. For example, if the value is "auto left", the tooltip will display on the left side when possible, otherwise on the right.

    Complete Bootstrap Tooltip Reference

    For a complete reference of all tooltip options, methods and events, go to our Bootstrap JS Tooltip Reference.

    Bootstrap Popover Plugin

    The Popover Plugin

    The Popover plugin is similar to tooltips; it is a pop-up box that appears when the user clicks on an element. The difference is that the popover can contain much more content. Click To Toggle Popover Tip: Plugins can be included individually (using Bootstrap's individual "popover.js" file), or all at once (using "bootstrap.js" or "bootstrap.min.js").

    How To Create a Popover

    To create a popover, add the data-toggle="popover" attribute to an element. Use the title attribute to specify the header text of the popover, and use the data-content attribute to specify the text that should be displayed inside the popover's body: <a href="#" data-toggle="popover" title="Popover Header" data-content="Some content inside the popover">Toggle popover</a> Note: Popovers must be initialized with jQuery: select the specified element and call the popover() method. The following code will enable all popovers in the document:

    Example

    <script> $(document).ready(function(){ $('[data-toggle="popover"]').popover(); }); </script> Try it Yourself »

    Positioning Popovers

    By default, the popover will appear on the right side of the element. Use the data-placement attribute to set the position of the popover on top, bottom, left or the right side of the element:

    Example

    <a href="#" title="Header" data-toggle="popover" data-placement="top" data-content="Content">Click</a> <a href="#" title="Header" data-toggle="popover" data-placement="bottom" data-content="Content">Click</a> <a href="#" title="Header" data-toggle="popover" data-placement="left" data-content="Content">Click</a> <a href="#" title="Header" data-toggle="popover" data-placement="right" data-content="Content">Click</a> Try it Yourself » Tip: You can also use the data-placement attribute with a value of "auto", which will let the browser decide the position of the popover. For example, if the value is "auto left", the popover will display on the left side when possible, otherwise on the right.

    Closing Popovers

    By default, the popover is closed when you click on the element again. However, you can use the data-trigger="focus" attribute which will close the popover when clicking outside the element:

    Example

    <a href="#" title="Dismissible popover" data-toggle="popover" data-trigger="focus" data-content="Click anywhere in the document to close this popover">Click me</a> Try it Yourself » Tip: If you want the popover to be displayed when you move the mouse pointer over the element, use the data-trigger attribute with a value of "hover":

    Example

    <a href="#" title="Header" data-toggle="popover" data-trigger="hover" data-content="Some content">Hover over me</a> Try it Yourself »

    Complete Bootstrap Popover Reference

    For a complete reference of all popover options, methods and events, go to our Bootstrap JS Popover Reference.

    Bootstrap Scrollspy Plugin (Advanced)

    The Scrollspy Plugin

    The Scrollspy plugin is used to automatically update links in a navigation list based on scroll position.

    How To Create a Scrollspy

    The following example shows how to create a scrollspy:

    Example

    <!-- The scrollable area --> <body data-spy="scroll" data-target=".navbar" data-offset="50"> <!-- The navbar - The <a> elements are used to jump to a section in the scrollable area --> <nav class="navbar navbar-inverse navbar-fixed-top"> ... <ul class="nav navbar-nav"> <li><a href="#section1">Section 1</a></li> ... </nav> <!-- Section 1 --> <div id="section1"> <h1>Section 1</h1> <p>Try to scroll this page and look at the navigation bar while scrolling!</p> </div> ... </body> Try it Yourself »

    Example Explained

    Add data-spy="scroll" to the element that should be used as the scrollable area (often this is the <body> element). Then add the data-target attribute with a value of the id or the class name of the navigation bar (.navbar). This is to make sure that the navbar is connected with the scrollable area. Note that scrollable elements must match the ID of the links inside the navbar's list items (<div id="section1"> matches <a href="#section1">). The optional data-offset attribute specifies the number of pixels to offset from top when calculating the position of scroll. This is useful when you feel that the links inside the navbar changes the active state too soon or too early when jumping to the scrollable elements. Default is 10 pixels. Requires relative positioning: The element with data-spy="scroll" requires the CSS position property, with a value of "relative" to work properly. In this example, we use Bootstrap's vertical navigation pills as menu:

    Example

    <body data-spy="scroll" data-target="#myScrollspy" data-offset="20"> <div class="container"> <div class="row"> <nav class="col-sm-3" id="myScrollspy"> <ul class="nav nav-pills nav-stacked"> <li><a href="#section1">Section 1</a></li> ... </ul> </nav> <div class="col-sm-9"> <div id="section1"> <h1>Section 1</h1> <p>Try to scroll this page and look at the navigation list while scrolling!</p> </div> ... </div> </div> </div> </body> Try it Yourself »

    Complete Bootstrap Scrollspy Reference

    For a complete reference of all scrollspy methods and events, go to our Bootstrap JS Scrollspy Reference.

    Bootstrap Affix Plugin (Advanced)

    The Affix Plugin

    The Affix plugin allows an element to become affixed (locked) to an area on the page. This is often used with navigation menus or social icon buttons, to make them "stick" at a specific area while scrolling up and down the page. The plugin toggles this behavior on and off (changes the value of CSS position from static to fixed), depending on scroll position. Example 1) An affixed navbar: Example 2) An affixed sidebar: With Affix, when we scroll up and down the page, the menu is always visible and locked in its position.

    How To Create an Affixed Navigation Menu

    The following example shows how to create a horizontal affixed navigation menu:

    Example

    <nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="197"> Try it Yourself » The following example shows how to create a vertical affixed navigation menu:

    Example

    <ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="205"> Try it Yourself »

    Example Explained

    Add data-spy="affix" to the element you want affixed. Optionally, add the data-offset-top|bottom attribute to calculate the position of the scroll.

    How it works

    The affix plugin toggles between three classes: .affix, .affix-top, and .affix-bottom. Each class represents a particular state. You must add CSS properties to handle the actual positions, with the exception of position:fixed on the .affix class.
  • The plugin adds the .affix-top or .affix-bottom class to indicate the element is in its top-most or bottom-most position. Positioning with CSS is not required at this point.
  • Scrolling past the affixed element triggers the actual affixing - This is where the plugin replaces the .affix-top or .affix-bottom class with the .affix class (sets position:fixed). At this point, you must add the CSS top or bottom property to position the affixed element in the page.
  • If a bottom offset is defined, scrolling past it replaces the .affix class with .affix-bottom. Since offsets are optional, setting one requires you to set the appropriate CSS. In this case, add position:absolute when necessary.
  • In the first example above, the Affix plugin adds the .affix class (position:fixed) to the <nav> element when we have scrolled 197 pixels from the top. If you open the example, you will also see that we added the CSS top property with a value of 0 to the .affix class. This is to make sure that the navbar stays at the top of the page at all time, when we have scrolled 197 pixels from the top.

    Scrollspy & Affix

    Using the Affix plugin together with the Scrollspy plugin:

    Horizontal Menu (Navbar)

    <body data-spy="scroll" data-target=".navbar" data-offset="50"> <nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="197"> ... </nav> </body> Try it Yourself »

    Vertical Menu (Sidenav)

    <body data-spy="scroll" data-target="#myScrollspy" data-offset="15"> <nav class="col-sm-3" id="myScrollspy"> <ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="205"> ... </nav> </body> Try it Yourself »

    Complete Bootstrap Affix Reference

    For a complete reference of all affix methods and events, go to our Bootstrap JS Affix Reference.

    Bootstrap Filters (Advanced)

    Bootstrap Filters

    Bootstrap does not have a component that allows filtering. However, we can use jQuery to filter / search for elements.

    Filter Tables

    Perform a case-insensitive search for items in a table:

    Example

    Type something in the input field to search the table for first names, last names or emails:
    Firstname Lastname Email
    John Doe john@example.com
    Mary Moe mary@mail.com
    July Dooley july@greatstuff.com
    Anja Ravendale a_r@test.com

    jQuery

    <script> $(document).ready(function(){ $("#myInput").on("keyup", function() { var value = $(this).val().toLowerCase(); $("#myTable tr").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1) }); }); }); </script> Try it Yourself » Example explained: We use jQuery to loop through each table rows to check if there are any text values that matches the value of the input field. The toggle() method hides the row (display:none) that does not match the search. We use the toLowerCase() method to convert the text to lower case, which makes the search case insensitive (allows "john", "John", and even "JOHN" on search).

    Filter Lists

    Perform a case-insensitive search for items in a list:

    Example

    Type something in the input field to search the list for items:
  • First item
  • Second item
  • Third item
  • Fourth
  • Try it Yourself »

    Filter Dropdowns

    Perform a case-insensitive search for items in a dropdown menu:

    Example

    Open the dropdown menu and type something in the input field to search for dropdown items:
  • HTML
  • CSS
  • JavaScript
  • jQuery
  • Bootstrap
  • Angular
  • Try it Yourself »

    Filter Anything

    Perform a case-insensitive search for text inside a div element:

    Example

    I am a paragraph. I am a div element inside div. Another paragraph. Try it Yourself »

    Bootstrap Grid System

    Bootstrap Grid System

    Bootstrap's grid system allows up to 12 columns across the page. If you do not want to use all 12 column individually, you can group the columns together to create wider columns:
    span 1span 1 span 1span 1span 1 span 1span 1span 1 span 1span 1span 1 span 1
    span 4 span 4 span 4
    span 4span 8
    span 6span 6
    span 12
    Bootstrap's grid system is responsive, and the columns will re-arrange depending on the screen size: On a big screen it might look better with the content organized in three columns, but on a small screen it would be better if the content items were stacked on top of each other. Tip: Remember that grid columns should add up to twelve for a row. More than that, columns will stack no matter the viewport.

    Grid Classes

    The Bootstrap grid system has four classes:
  • xs (for phones - screens less than 768px wide)
  • sm (for tablets - screens equal to or greater than 768px wide)
  • md (for small laptops - screens equal to or greater than 992px wide)
  • lg (for laptops and desktops - screens equal to or greater than 1200px wide)
  • The classes above can be combined to create more dynamic and flexible layouts. Tip: Each class scales up, so if you wish to set the same widths for xs and sm, you only need to specify xs.

    Grid System Rules

    Some Bootstrap grid system rules:
  • Rows must be placed within a .container (fixed-width) or .container-fluid (full-width) for proper alignment and padding
  • Use rows to create horizontal groups of columns
  • Content should be placed within columns, and only columns may be immediate children of rows
  • Predefined classes like .row and .col-sm-4 are available for quickly making grid layouts
  • Columns create gutters (gaps between column content) via padding. That padding is offset in rows for the first and last column via negative margin on .rows
  • Grid columns are created by specifying the number of 12 available columns you wish to span. For example, three equal columns would use three .col-sm-4
  • Column widths are in percentage, so they are always fluid and sized relative to their parent element
  • Basic Structure of a Bootstrap Grid

    The following is a basic structure of a Bootstrap grid: <div class="container"> <div class="row"> <div class="col-*-*"></div> <div class="col-*-*"></div> </div> <div class="row"> <div class="col-*-*"></div> <div class="col-*-*"></div> <div class="col-*-*"></div> </div> <div class="row"> ... </div> </div> So, to create the layout you want, create a container (<div class="container">). Next, create a row (<div class="row">). Then, add the desired number of columns (tags with appropriate .col-*-* classes). Note that numbers in .col-*-* should always add up to 12 for each row.

    Grid Options

    The following table summarizes how the Bootstrap grid system works across multiple devices:
    Extra small <768pxSmall >=768pxMedium >=992pxLarge >=1200px
    Class prefix.col-xs-.col-sm-.col-md-.col-lg-
    Suitable forPhonesTabletsSmall LaptopsLaptops & Desktops
    Grid behaviourHorizontal at all timesCollapsed to start, horizontal above breakpointsCollapsed to start, horizontal above breakpointsCollapsed to start, horizontal above breakpoints
    Container widthNone (auto)750px970px1170px
    # of columns12121212
    Column widthAuto~62px~81px~97px
    Gutter width30px (15px on each side of a column)30px (15px on each side of a column)30px (15px on each side of a column)30px (15px on each side of a column)
    NestableYesYesYesYes
    OffsetsYesYesYesYes
    Column orderingYesYesYesYes

    Examples

    The next chapters shows examples of grid systems for different devices:
  • Stacked-to-horizontal
  • Small devices
  • Medium devices
  • Large devices
  • More grid examples
  • Bootstrap Grid - Stacked-to-horizontal

    Bootstrap Grid Example: Stacked-to-horizontal

    We will create a basic grid system that starts out stacked on extra small devices, before becoming horizontal on larger devices. The following example shows a simple "stacked-to-horizontal" two-column layout, meaning it will result in a 50%/50% split on all screens, except for extra small screens, which it will automatically stack (100%): col-sm-6 col-sm-6

    Example: Stacked-to-horizontal

    <div class="container"> <h1>Hello World!</h1> <div class="row"> <div class="col-sm-6" style="background-color:yellow;"> <p>Lorem ipsum...</p> </div> <div class="col-sm-6" style="background-color:pink;"> <p>Sed ut perspiciatis...</p> </div> </div> </div> Try it Yourself » Tip: The numbers in the .col-sm-* classes indicates how many columns the div should span (out of 12). So, .col-sm-1 spans 1 column, .col-sm-4 spans 4 columns, .col-sm-6 spans 6 columns, etc. Note: Make sure that the sum always adds up to 12! Tip: You can turn any fixed-width layout into a full-width layout by changing the .container class to .container-fluid:

    Example: Fluid container

    <div class="container-fluid"> <h1>Hello World!</h1> <div class="row"> <div class="col-sm-6" style="background-color:yellow;"> <p>Lorem ipsum...</p> </div> <div class="col-sm-6" style="background-color:pink;"> <p>Sed ut perspiciatis...</p> </div> </div> </div> Try it Yourself »

    Bootstrap Grid - Small Devices

    Bootstrap Grid Example: Small Devices

    Extra smallSmallMediumLarge
    Class prefix.col-xs .col-sm.col-md .col-lg
    Screen width<768px >=768px>=992px>=1200px
    Assume we have a simple layout with two columns. We want the columns to be split 25%/75% for small devices. Tip: Small devices are defined as having a screen width from 768 pixels to 991 pixels. For small devices we will use the .col-sm-* classes. We will add the following classes to our two columns: <div class="col-sm-3">....</div> <div class="col-sm-9">....</div> Now Bootstrap is going to say "at the small size, look for classes with -sm- in them and use those". The following example will result in a 25%/75% split on small (and medium and large) devices. On extra small devices, it will automatically stack (100%): col-sm-3 col-sm-9

    Example

    <div class="container-fluid"> <h1>Hello World!</h1> <div class="row"> <div class="col-sm-3" style="background-color:yellow;"> <p>Lorem ipsum...</p> </div> <div class="col-sm-9" style="background-color:pink;"> <p>Sed ut perspiciatis...</p> </div> </div> </div> Try it Yourself » Note: Make sure that the sum always adds up to 12. For a 33.3%/66.6% split, you would use .col-sm-4 and .col-sm-8: col-sm-4 col-sm-8

    Example

    <div class="container-fluid"> <h1>Hello World!</h1> <div class="row"> <div class="col-sm-4" style="background-color:yellow;"> <p>Lorem ipsum...</p> </div> <div class="col-sm-8" style="background-color:pink;"> <p>Sed ut perspiciatis...</p> </div> </div> </div> Try it Yourself » The next chapter shows how to add a different split percent for medium devices.

    Bootstrap Grid - Medium Devices

    Bootstrap Grid Example: Medium Devices

    Extra smallSmallMediumLarge
    Class prefix.col-xs.col-sm .col-md .col-lg
    Screen width<768px>=768px >=992px>=1200px
    In the previous chapter, we presented a grid example with classes for small devices. We used two divs (columns) and we gave them a 25%/75% split: <div class="col-sm-3">....</div> <div class="col-sm-9">....</div> But on medium devices the design may be better as a 50%/50% split. Tip: Medium devices are defined as having a screen width from 992 pixels to 1199 pixels. For medium devices we will use the .col-md-* classes. Now we will add the column widths for medium devices: <div class="col-sm-3 col-md-6">....</div> <div class="col-sm-9 col-md-6">....</div> Now Bootstrap is going to say "at the small size, look at classes with -sm- in them and use those. At the medium size, look at classes with -md- in them and use those". The following example will result in a 25%/75% split on small devices and a 50%/50% split on medium (and large) devices. On extra small devices, it will automatically stack (100%):

    Example

    <div class="container-fluid"> <h1>Hello World!</h1> <div class="row"> <div class="col-sm-3 col-md-6" style="background-color:yellow;"> <p>Lorem ipsum...</p> </div> <div class="col-sm-9 col-md-6" style="background-color:pink;"> <p>Sed ut perspiciatis...</p> </div> </div> </div> Try it Yourself » Note: Make sure that the sum always adds up to 12.

    Using Only Medium

    In the example below, we only specify the .col-md-6 class (without .col-sm-*). This means that medium and large devices will split 50%/50% - because the class scales up. However, for small devices, it will stack vertically (100% width):

    Example

    <div class="row"> <div class="col-md-6" style="background-color:yellow;"> <p>Lorem ipsum...</p> </div> <div class="col-md-6" style="background-color:pink;"> <p>Sed ut perspiciatis...</p> </div> </div> Try it Yourself » The next chapter shows how to add a different split percent for large devices.

    Bootstrap Grid - Large Devices

    Bootstrap Grid Example: Large Devices

    Extra smallSmallMediumLarge
    Class prefix.col-xs.col-sm.col-md .col-lg
    Screen width<768px>=768px>=992px >=1200px
    In the previous chapter, we presented a grid example with classes for small and medium devices. We used two divs (columns) and we gave them a 25%/75% split on small devices, and a 50%/50% split on medium devices: <div class="col-sm-3 col-md-6">....</div> <div class="col-sm-9 col-md-6">....</div> But on large devices the design may be better as a 33%/66% split. Tip: Large devices are defined as having a screen width from 1200 pixels and above. For large devices we will use the .col-lg-* classes. So now we will add the column widths for large devices: <div class="col-sm-3 col-md-6 col-lg-4">....</div> <div class="col-sm-9 col-md-6 col-lg-8">....</div> Now Bootstrap is going to say "at the small size, look at classes with -sm- in them and use those. At the medium size, look at classes with -md- in them and use those. At the large size, look at classes with the word -lg- in them and use those". The following example will result in a 25%/75% split on small devices, a 50%/50% split on medium devices, and a 33%/66% split on large devices:

    Example

    <div class="container-fluid"> <h1>Hello World!</h1> <div class="row"> <div class="col-sm-3 col-md-6 col-lg-4" style="background-color:yellow;"> <p>Lorem ipsum...</p> </div> <div class="col-sm-9 col-md-6 col-lg-8" style="background-color:pink;"> <p>Sed ut perspiciatis...</p> </div> </div> </div> Try it Yourself » Note: Make sure that the sum always adds up to 12.

    Using Only Large

    In the example below, we only specify the .col-lg-6 class (without .col-md-* and/or .col-sm-*). This means that large devices will split 50%/50%. However, for medium AND small devices, it will stack vertically (100% width):

    Example

    <div class="container-fluid"> <h1>Hello World!</h1> <div class="row"> <div class="col-lg-6" style="background-color:yellow;"> <p>Lorem ipsum...</p> </div> <div class="col-lg-6" style="background-color:pink;"> <p>Sed ut perspiciatis...</p> </div> </div> </div> Try it Yourself »

    Bootstrap Grid Examples

    Below we have collected some examples of basic Bootstrap grid layouts.

    Three Equal Columns

    .col-sm-4 .col-sm-4 .col-sm-4 The following example shows how to get a three equal-width columns starting at tablets and scaling to large desktops. On mobile phones, the columns will automatically stack:

    Example

    <div class="row"> <div class="col-sm-4">.col-sm-4</div> <div class="col-sm-4">.col-sm-4</div> <div class="col-sm-4">.col-sm-4</div> </div> Try it Yourself »

    Three Unequal Columns

    .col-sm-3 .col-sm-6 .col-sm-3 The following example shows how to get a three various-width columns starting at tablets and scaling to large desktops:

    Example

    <div class="row"> <div class="col-sm-3">.col-sm-3</div> <div class="col-sm-6">.col-sm-6</div> <div class="col-sm-3">.col-sm-3</div> </div> Try it Yourself »

    Two Unequal Columns

    .col-sm-4 .col-sm-8 The following example shows how to get two various-width columns starting at tablets and scaling to large desktops:

    Example

    <div class="row"> <div class="col-sm-4">.col-sm-4</div> <div class="col-sm-8">.col-sm-8</div> </div> Try it Yourself »

    No gutters

    .col-sm-4 .col-sm-8 Use the .row-no-gutters class to remove the gutters from a row and its columns:

    Example

    <div class="row row-no-gutters"> <div class="col-sm-3">.col-sm-3</div> <div class="col-sm-6">.col-sm-6</div> <div class="col-sm-3">.col-sm-3</div> </div> Try it Yourself »

    Two Columns With Two Nested Columns

    The following example shows how to get two columns starting at tablets and scaling to large desktops, with another two columns (equal widths) within the larger column (at mobile phones, these columns and their nested columns will stack):

    Example

    <div class="row"> <div class="col-sm-8"> .col-sm-8 <div class="row"> <div class="col-sm-6">.col-sm-6</div> <div class="col-sm-6">.col-sm-6</div> </div> </div> <div class="col-sm-4">.col-sm-4</div> </div> Try it Yourself »

    Mixed: Mobile And Desktop

    The Bootstrap grid system has four classes: xs (phones), sm (tablets), md (desktops), and lg (larger desktops). The classes can be combined to create more dynamic and flexible layouts. Tip: Each class scales up, so if you wish to set the same widths for xs and sm, you only need to specify xs.

    Example

    <div class="row"> <div class="col-xs-9 col-md-7">.col-xs-9 .col-md-7</div> <div class="col-xs-3 col-md-5">.col-xs-3 .col-md-5</div> </div> <div class="row"> <div class="col-xs-6 col-md-10">.col-xs-6 .col-md-10</div> <div class="col-xs-6 col-md-2">.col-xs-6 .col-md-2</div> </div> <div class="row"> <div class="col-xs-6">.col-xs-6</div> <div class="col-xs-6">.col-xs-6</div> </div> Try it Yourself » Tip: Remember that grid columns should add up to twelve for a row. More than that, columns will stack no matter the viewport.

    Mixed: Mobile, Tablet And Desktop

    Example

    <div class="row"> <div class="col-xs-7 col-sm-6 col-lg-8">.col-xs-7 .col-sm-6 .col-lg-8</div> <div class="col-xs-5 col-sm-6 col-lg-4">.col-xs-5 .col-sm-6 .col-lg-4</div> </div> <div class="row"> <div class="col-xs-6 col-sm-8 col-lg-10">.col-xs-6 .col-sm-8 .col-lg-10</div> <div class="col-xs-6 col-sm-4 col-lg-2">.col-xs-6 .col-sm-4 .col-lg-2</div> </div> Try it Yourself »

    Clear Floats

    Clear floats (with the .clearfix class) at specific breakpoints to prevent strange wrapping with uneven content:

    Example

    <div class="row"> <div class="col-xs-6 col-sm-3"> Column 1 <br> Resize the browser window to see the effect. </div> <div class="col-xs-6 col-sm-3">Column 2</div> <!-- Add clearfix for only the required viewport --> <div class="clearfix visible-xs"></div> <div class="col-xs-6 col-sm-3">Column 3</div> <div class="col-xs-6 col-sm-3">Column 4</div> </div> Try it Yourself »

    Offsetting Columns

    Move columns to the right using .col-md-offset-* classes. These classes increase the left margin of a column by * columns:

    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"> </div> Try it Yourself »

    Push And Pull - Change Column Ordering

    Change the order of the grid columns with .col-md-push-* and .col-md-pull-* classes:

    Example

    <div class="row"> <div class="col-sm-4 col-sm-push-8">.col-sm-4 .col-sm-push-8</div> <div class="col-sm-8 col-sm-pull-4">.col-sm-8 .col-sm-pull-4</div> </div> Try it Yourself »

    Bootstrap Templates

    W3Schools' Bootstrap Templates

    We have used Bootstrap's grid system to create some responsive HTML templates. They are completely free - Click on "Try It Yourself" to see the code and do whatever you want with it: Blog: Try it Yourself » Portfolio: Try it Yourself » Webpage: Try it Yourself » Social: Try it Yourself » Marketing: Try it Yourself » Marketing 2: Try it Yourself » Analytics: Try it Yourself » Online Store: Try it Yourself »

    Bootstrap Theme "Simply Me"

    Create a Theme: "Simply Me"

    This page will show you how to build a Bootstrap theme from scratch. We will start with a simple HTML page, and then add more and more components, until we have a fully functional, personal and responsive website. The result will look like this, and you are free to modify, save, share, use or do whatever you want with it: Full Page Demo Full Source Code We will start with the following HTML page: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Theme Simply Me</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <h3>Who Am I?</h3> <img src="bird.jpg"><h3>I'm an adventurer</h3> </body> </html>

    Add Bootstrap CDN and Put Elements in Container

    Add Bootstrap CDN and a link to jQuery and put HTML elements inside a container:

    Example

    <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Theme Simply Me</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> </head> <body> <div class="container-fluid"> <h3>Who Am I?</h3> <img src="bird.jpg"> <h3>I'm an adventurer</h3> </div> </body> </html> Result:

    Who Am I?

    I'm an adventurer

    Try it Yourself »

    Add Background Color and Center Text

    1. Add a custom class (.bg-1) to the container to add a background color. 2. Add the .text-center class to center the text inside the container:

    Example

    <head> <style> .bg-1 { background-color: #1abc9c; /* Green */ color: #ffffff; } </style> </head> <body> <div class="container-fluid bg-1 text-center"> <h3>Who Am I?</h3> <img src="bird.jpg"> <h3>I'm an adventurer</h3> </div> </body> Result:

    Who Am I?

    I'm an adventurer

    Try it Yourself »

    Circle Image

    Shape the image to a circle with the .img-circle class:

    Example

    <img src="bird.jpg" class="img-circle" alt="Bird"> Result:

    Who Am I?

    I'm an adventurer

    Try it Yourself »

    More Content

    Add more content and put it inside new containers:

    Example

    <head> <style> .bg-1 { background-color: #1abc9c; /* Green */ color: #ffffff; } .bg-2 { background-color: #474e5d; /* Dark Blue */ color: #ffffff; } .bg-3 { background-color: #ffffff; /* White */ color: #555555; } </style> </head> <body> <div class="container-fluid bg-1 text-center"> <h3>Who Am I?</h3> <img src="bird.jpg" class="img-circle" alt="Bird"> <h3>I'm an adventurer</h3> </div> <div class="container-fluid bg-2 text-center"> <h3>What Am I?</h3> <p>Lorem ipsum..</p> </div> <div class="container-fluid bg-3 text-center"> <h3>Where To Find Me?</h3> <p>Lorem ipsum..</p> </div> </body> Result:

    Who Am I?

    Bird

    I'm an adventurer

    What Am I?

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

    Where To Find Me?

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Try it Yourself »

    Add Padding

    Lets make the containers look good by adding some padding:

    Example

    <style> .container-fluid { padding-top: 70px; padding-bottom: 70px; } </style> Result:

    Who Am I?

    Bird

    I'm an adventurer

    What Am I?

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

    Where To Find Me?

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Try it Yourself »

    Add a Button

    Add a button to the mid container:

    Example

    <div class="container-fluid bg-2 text-center"> <h3>What Am I?</h3> <p>Lorem ipsum..</p> <a href="#" class="btn btn-default btn-lg">Search</a> </div> Result:

    What Am I?

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Search Try it Yourself »

    Add an Icon

    Add a Search icon on the "Search" button:

    Example

    <a href="#" class="btn btn-default btn-lg"> <span class="glyphicon glyphicon-search"></span> Search </a> Result: Search Try it Yourself »

    Modify The Third Container (Add Grid)

    Add three columns of equal width inside the third container (.col-sm-4):

    Example

    <div class="container-fluid bg-3 text-center"> <h3>Where To Find Me?</h3> <div class="row"> <div class="col-sm-4"> <p>Lorem ipsum..</p> <img src="birds1.jpg" alt="Image"> </div> <div class="col-sm-4"> <p>Lorem ipsum..</p> <img src="birds2.jpg" alt="Image"> </div> <div class="col-sm-4"> <p>Lorem ipsum..</p> <img src="birds3.jpg" alt="Image"> </div> </div> </div> Result:

    Where To Find Me?

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Image Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Image Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Image Try it Yourself »

    Make The Images Responsive

    Add the .img-responsive class to all images. Add display:inline to the first image to force it to be centered (the .img-responsive class adds display:block to the image, which makes it jump to the left of the screen). If you want the image to span the entire width of the screen when it starts to stack, add width:100% to the image. When opening the example, remember to resize the screen to see the responsive effect:

    Example

    <!-- The circular bird --> <img src="bird.jpg" class="img-responsive img-circle" style="display:inline" alt="Bird"> <!-- The birds in our grid: --> <img src="birds1.jpg" class="img-responsive" style="width:100%" alt="Image"> <img src="birds2.jpg" class="img-responsive" style="width:100%" alt="Image"> <img src="birds3.jpg" class="img-responsive" style="width:100%" alt="Image"> Try it Yourself »

    Add a Navbar

    Add a standard navigation bar at the top of the page with and make it collapsible on smaller screens:

    Example

    <nav class="navbar navbar-default"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Me</a> </div> <div class="collapse navbar-collapse" id="myNavbar"> <ul class="nav navbar-nav navbar-right"> <li><a href="#">WHO</a></li> <li><a href="#">WHAT</a></li> <li><a href="#">WHERE</a></li> </ul> </div> </div> </nav> Result: Try it Yourself »

    Style The Navbar

    Use CSS to customize the navigation bar:

    Example

    .navbar { padding-top: 15px; padding-bottom: 15px; border: 0; border-radius: 0; margin-bottom: 0; font-size: 12px; letter-spacing: 5px; } .navbar-nav li a:hover { color: #1abc9c !important; } Result: Try it Yourself »

    Add a Footer

    Add a footer and use CSS to style it:

    Example

    <style> .bg-4 { background-color: #2f2f2f; color: #ffffff; } </style> <footer class="container-fluid bg-4 text-center"> <p>Bootstrap Theme Made By <a href="https://www.w3schools.com">www.w3schools.com</a></p> </footer> Result: Try it Yourself »

    Final Touch

    Personalize your Theme by adding a font that you like. We have used "Montserrat" from Google's Font Library. Link to the font in the <head> section: <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet"> Then you can use it in the page:

    Example

    body { font: 20px "Montserrat", sans-serif; line-height: 1.8; color: #f5f6f7; } p {font-size: 16px;} We have also created a "helper" margin class to add extra space where we think it's needed; usually after each <h3> and <img> element.

    Example

    .margin {margin-bottom: 45px;} Try it Yourself »

    Complete "Simply Me" Theme

    Full Page Demo Full Source Code

    Bootstrap Theme "Company"

    Create a Theme: "Company"

    This page will show you how to build a Bootstrap theme from scratch. We will start with a simple HTML page, and then add more and more components, until we have a fully functional, personal and responsive website. The result will look like this, and you are free to modify, save, share, use or do whatever you want with it: Full Page Demo Full Source Code We will start with the following HTML page: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Theme Company</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <h1>Company</h1> <p>We specialize in blablabla</p> </body> </html>

    Add Bootstrap CDN and Add a Jumbotron

    Add Bootstrap CDN and a link to jQuery and put HTML elements inside a .jumbotron:

    Example

    <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Theme Company</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> </head> <body> <div class="jumbotron"> <h1>Company</h1> <p>We specialize in blablabla</p> </div> </body> </html> Result:

    Company

    We specialize in blablabla Try it Yourself »

    Add Background Color and Center Text

    1. Add an orange background color to the jumbotron. 2. Add the .text-center class to center the text inside the jumbotron:

    Example

    <style> .jumbotron { background-color: #f4511e; /* Orange */ color: #ffffff; } </style> <body> <div class="jumbotron text-center"> <h1>Company</h1> <p>We specialize in blablabla</p> </div> </body> Result:

    Company

    We specialize in blablabla Try it Yourself »

    Add Form

    Add a form with an input field and a button:

    Example

    <div class="jumbotron text-center"> <h1>Company</h1> <p>We specialize in blablabla</p> <form class="form-inline"> <div class="input-group"> <input type="email" class="form-control" size="50" placeholder="Email Address" required> <div class="input-group-btn"> <button type="button" class="btn btn-danger">Subscribe</button> </div> </div> </form> </div> Result:

    Company

    We specialize in blablabla
    Try it Yourself »

    Add Containers

    Add two containers (.container-fluid), and add a custom class to the second container (.bg-grey - adds a gray background color):

    Example

    <style> .bg-grey { background-color: #f6f6f6; } </style> <div class="container-fluid"> <h2>About Company Page</h2> <h4>Lorem ipsum..</h4> <p>Lorem ipsum..</p> <button class="btn btn-default btn-lg">Get in Touch</button> </div> <div class="container-fluid bg-grey"> <h2>Our Values</h2> <h4><strong>MISSION:</strong> Our mission lorem ipsum..</h4> <p><strong>VISION:</strong> Our vision Lorem ipsum.. </div> Result:

    About Company Page

    Lorem ipsum..

    Lorem ipsum..

    Our Values

    MISSION: Our mission lorem ipsum..

    VISION: Our vision Lorem ipsum.. Try it Yourself »

    Add Padding

    Lets make the jumbotron and the containers look good by adding some padding:

    Example

    <style> .jumbotron { background-color: #f4511e; color: #fff; padding: 100px 25px; } .container-fluid { padding: 60px 50px; } </style> Result:

    Company

    We specialize in blablabla

    About Company Page

    Lorem ipsum..

    Lorem ipsum..

    Our Values

    MISSION: Our mission lorem ipsum..

    VISION: Our vision Lorem ipsum.. Try it Yourself »

    Add a Grid

    1. Add an icon (or the company's logo) to each container. 2. Separate the icon and the "about text" by creating two columns (.col-sm-8 and .col-sm-4) 3. Add media queries to center the "logo column" on screens smaller than 768 pixels wide.

    Example

    <style> .logo { font-size: 200px; } @media screen and (max-width: 768px) { .col-sm-4 { text-align: center; margin: 25px 0; } } </style> <div class="container-fluid"> <div class="row"> <div class="col-sm-8"> <h2>About Company Page</h2> <h4>Lorem ipsum..</h4> <p>Lorem ipsum..</p> <button class="btn btn-default btn-lg">Get in Touch</button> </div> <div class="col-sm-4"> <span class="glyphicon glyphicon-signal logo"></span> </div> </div> </div> <div class="container-fluid bg-grey"> <div class="row"> <div class="col-sm-4"> <span class="glyphicon glyphicon-globe logo"></span> </div> <div class="col-sm-8"> <h2>Our Values</h2> <h4><strong>MISSION:</strong> Our mission lorem ipsum..</h4> <p><strong>VISION:</strong> Our vision Lorem ipsum..</p> </div> </div> </div> Result:

    About Company Page

    Lorem ipsum..

    Lorem ipsum..

    Our Values

    MISSION: Our mission lorem ipsum..

    VISION: Our vision Lorem ipsum.. Try it Yourself »

    Add Services Container

    Add a new container, with 2x3 columns of equal width (.col-sm-4):

    Example

    <div class="container-fluid text-center"> <h2>SERVICES</h2> <h4>What we offer</h4> <br> <div class="row"> <div class="col-sm-4"> <span class="glyphicon glyphicon-off"></span> <h4>POWER</h4> <p>Lorem ipsum dolor sit amet..</p> </div> <div class="col-sm-4"> <span class="glyphicon glyphicon-heart"></span> <h4>LOVE</h4> <p>Lorem ipsum dolor sit amet..</p> </div> <div class="col-sm-4"> <span class="glyphicon glyphicon-lock"></span> <h4>JOB DONE</h4> <p>Lorem ipsum dolor sit amet..</p> </div> </div> <br><br> <div class="row"> <div class="col-sm-4"> <span class="glyphicon glyphicon-leaf"></span> <h4>GREEN</h4> <p>Lorem ipsum dolor sit amet..</p> </div> <div class="col-sm-4"> <span class="glyphicon glyphicon-certificate"></span> <h4>CERTIFIED</h4> <p>Lorem ipsum dolor sit amet..</p> </div> <div class="col-sm-4"> <span class="glyphicon glyphicon-wrench"></span> <h4>HARD WORK</h4> <p>Lorem ipsum dolor sit amet..</p> </div> </div> </div> Result:

    SERVICES

    What we offer

    POWER

    Lorem ipsum dolor sit amet..

    LOVE

    Lorem ipsum dolor sit amet..

    JOB DONE

    Lorem ipsum dolor sit amet..

    GREEN

    Lorem ipsum dolor sit amet..

    CERTIFIED

    Lorem ipsum dolor sit amet..

    HARD WORK

    Lorem ipsum dolor sit amet.. Try it Yourself »

    Styling Icons

    Add a custom class (.logo-small) to each glyphicon in the "Services" container. Use CSS to style them:

    Example

    /* Add an orange color to all icons and set the font-size */ .logo-small { color: #f4511e; font-size: 50px; } .logo { color: #f4511e; font-size: 200px; } Result:

    About Company Page

    Lorem ipsum..

    Lorem ipsum..

    Our Values

    MISSION: Our mission lorem ipsum..

    VISION: Our vision Lorem ipsum..

    SERVICES

    What we offer

    POWER

    Lorem ipsum dolor sit amet..

    LOVE

    Lorem ipsum dolor sit amet..

    JOB DONE

    Lorem ipsum dolor sit amet..

    GREEN

    Lorem ipsum dolor sit amet..

    CERTIFIED

    Lorem ipsum dolor sit amet..

    HARD WORK

    Lorem ipsum dolor sit amet.. Try it Yourself »

    Add Portfolio Container

    Create a new full-width container, with three columns of equal width (.col-sm-4): Inside each column, add an image. Then, use the .img-thumbnail class to shape the image to a thumbnail. Normally, you would add the .img-thumbnail class directly to the <img> element. In this example, we have placed a thumbnail container around the image, so that we can specify an image text as well.

    Example

    <div class="container-fluid text-center bg-grey"> <h2>Portfolio</h2> <h4>What we have created</h4> <div class="row text-center"> <div class="col-sm-4"> <div class="thumbnail"> <img src="paris.jpg" alt="Paris"> <p><strong>Paris</strong></p> <p>Yes, we built Paris</p> </div> </div> <div class="col-sm-4"> <div class="thumbnail"> <img src="newyork.jpg" alt="New York"> <p><strong>New York</strong></p> <p>We built New York</p> </div> </div> <div class="col-sm-4"> <div class="thumbnail"> <img src="sanfran.jpg" alt="San Francisco"> <p><strong>San Francisco</strong></p> <p>Yes, San Fran is ours</p> </div> </div> </div> Result:

    Portfolio

    What we have created

    Paris Yes, we built Paris New York We built New York San Francisco Yes, San Fran is ours Try it Yourself »

    Styling Thumbnail Images

    Use CSS to style the images. In our example, we have tried to make them look like cards, by removing their border, and set a 100% width on each image.

    Example

    .thumbnail { padding: 0 0 15px 0; border: none; border-radius: 0; } .thumbnail img { width: 100%; height: 100%; margin-bottom: 10px; } Result:

    Portfolio

    What we have created

    Paris Yes, we built Paris New York We built New York San Francisco Yes, San Fran is ours Try it Yourself »

    Add a Carousel

    Add a carousel:

    Example

    <h2>What our customers say</h2> <div id="myCarousel" class="carousel slide text-center" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#myCarousel" data-slide-to="0" class="active"></li> <li data-target="#myCarousel" data-slide-to="1"></li> <li data-target="#myCarousel" data-slide-to="2"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner" role="listbox"> <div class="item active"> <h4>"This company is the best. I am so happy with the result!"<br><span style="font-style:normal;">Michael Roe, Vice President, Comment Box</span></h4> </div> <div class="item"> <h4>"One word... WOW!!"<br><span style="font-style:normal;">John Doe, Salesman, Rep Inc</span></h4> </div> <div class="item"> <h4>"Could I... BE any more happy with this company?"<br><span style="font-style:normal;">Chandler Bing, Actor, FriendsAlot</span></h4> </div> </div> <!-- Left and right controls --> <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> Result:

    What our customers say

    "This company is the best. I am so happy with the result!" Michael Roe, Vice President, Comment Box

    "One word... WOW!!" John Doe, Salesman, Rep Inc

    "Could I... BE any more happy with this company?" Chandler Bing, Actor, FriendsAlot

    Previous Next Try it Yourself »

    Style The Carousel

    Use CSS to style the carousel:

    Example

    .carousel-control.right, .carousel-control.left { background-image: none; color: #f4511e; } .carousel-indicators li { border-color: #f4511e; } .carousel-indicators li.active { background-color: #f4511e; } .item h4 { font-size: 19px; line-height: 1.375em; font-weight: 400; font-style: italic; margin: 70px 0; } .item span { font-style: normal; } Result:

    What our customers say

    "This company is the best. I am so happy with the result!" Michael Roe, Vice President, Comment Box

    "One word... WOW!!" John Doe, Salesman, Rep Inc

    "Could I... BE any more happy with this company?" Chandler Bing, Actor, FriendsAlot

    Previous Next Try it Yourself »

    Add Pricing Container

    Create a full width container, with three columns of equal width (.col-sm-4): Inside each column, add a panel:

    Example

    <div class="container-fluid"> <div class="text-center"> <h2>Pricing</h2> <h4>Choose a payment plan that works for you</h4> </div> <div class="row"> <div class="col-sm-4"> <div class="panel panel-default text-center"> <div class="panel-heading"> <h1>Basic</h1> </div> <div class="panel-body"> <p><strong>20</strong> Lorem</p> <p><strong>15</strong> Ipsum</p> <p><strong>5</strong> Dolor</p> <p><strong>2</strong> Sit</p> <p><strong>Endless</strong> Amet</p> </div> <div class="panel-footer"> <h3>$19</h3> <h4>per month</h4> <button class="btn btn-lg">Sign Up</button> </div> </div> </div> <div class="col-sm-4"> <div class="panel panel-default text-center"> <div class="panel-heading"> <h1>Pro</h1> </div> <div class="panel-body"> <p><strong>50</strong> Lorem</p> <p><strong>25</strong> Ipsum</p> <p><strong>10</strong> Dolor</p> <p><strong>5</strong> Sit</p> <p><strong>Endless</strong> Amet</p> </div> <div class="panel-footer"> <h3>$29</h3> <h4>per month</h4> <button class="btn btn-lg">Sign Up</button> </div> </div> </div> <div class="col-sm-4"> <div class="panel panel-default text-center"> <div class="panel-heading"> <h1>Premium</h1> </div> <div class="panel-body"> <p><strong>100</strong> Lorem</p> <p><strong>50</strong> Ipsum</p> <p><strong>25</strong> Dolor</p> <p><strong>10</strong> Sit</p> <p><strong>Endless</strong> Amet</p> </div> <div class="panel-footer"> <h3>$49</h3> <h4>per month</h4> <button class="btn btn-lg">Sign Up</button> </div> </div> </div> </div> </div> Result:

    Pricing

    Choose a payment plan that works for you

    Basic

    20 Lorem 15 Ipsum 5 Dolor 2 Sit Endless Amet

    $19

    per month

    Pro

    50 Lorem 25 Ipsum 10 Dolor 5 Sit Endless Amet

    $29

    per month

    Premium

    100 Lorem 50 Ipsum 25 Dolor 10 Sit Endless Amet

    $49

    per month

    Try it Yourself »

    Styling Panels

    Use CSS to style the panels:

    Example

    .panel { border: 1px solid #f4511e; border-radius:0; transition: box-shadow 0.5s; } .panel:hover { box-shadow: 5px 0px 40px rgba(0,0,0, .2); } .panel-footer .btn:hover { border: 1px solid #f4511e; background-color: #fff !important; color: #f4511e; } .panel-heading { color: #fff !important; background-color: #f4511e !important; padding: 25px; border-bottom: 1px solid transparent; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; } .panel-footer { background-color: #fff !important; } .panel-footer h3 { font-size: 32px; } .panel-footer h4 { color: #aaa; font-size: 14px; } .panel-footer .btn { margin: 15px 0; background-color: #f4511e; color: #fff; } Result:

    Pricing

    Choose a payment plan that works for you

    Basic

    20 Lorem 15 Ipsum 5 Dolor 2 Sit Endless Amet

    $19

    per month

    Pro

    50 Lorem 25 Ipsum 10 Dolor 5 Sit Endless Amet

    $29

    per month

    Premium

    100 Lorem 50 Ipsum 25 Dolor 10 Sit Endless Amet

    $49

    per month

    Try it Yourself »

    Add Contact Container

    Add a new container with contact information:

    Example

    <div class="container-fluid bg-grey"> <h2 class="text-center">CONTACT</h2> <div class="row"> <div class="col-sm-5"> <p>Contact us and we'll get back to you within 24 hours.</p> <p><span class="glyphicon glyphicon-map-marker"></span> Chicago, US</p> <p><span class="glyphicon glyphicon-phone"></span> +00 1515151515</p> <p><span class="glyphicon glyphicon-envelope"></span> myemail@something.com</p> </div> <div class="col-sm-7"> <div class="row"> <div class="col-sm-6 form-group"> <input class="form-control" id="name" name="name" placeholder="Name" type="text" required> </div> <div class="col-sm-6 form-group"> <input class="form-control" id="email" name="email" placeholder="Email" type="email" required> </div> </div> <textarea class="form-control" id="comments" name="comments" placeholder="Comment" rows="5"></textarea><br> <div class="row"> <div class="col-sm-12 form-group"> <button class="btn btn-default pull-right" type="submit">Send</button> </div> </div> </div> </div> </div> Result:

    CONTACT

    Contact us and we'll get back to you within 24 hours. Chicago, US +00 1515151515 myemail@something.com Try it Yourself »

    Add Map/Location Image

    Add a location image or a map (read our Google Maps Tutorial for google maps):

    Example

    <!-- Image of location/map --> <img src="map.jpg" style="width:100%"> Result: Try it Yourself »

    Add a Navbar

    Add a navbar at the top of the page that collapses on smaller screens:

    Example

    <nav class="navbar navbar-default navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Logo</a> </div> <div class="collapse navbar-collapse" id="myNavbar"> <ul class="nav navbar-nav navbar-right"> <li><a href="#about">ABOUT</a></li> <li><a href="#services">SERVICES</a></li> <li><a href="#portfolio">PORTFOLIO</a></li> <li><a href="#pricing">PRICING</a></li> <li><a href="#contact">CONTACT</a></li> </ul> </div> </div> </nav> Result: Try it Yourself » Tip: Right-align the navigation buttons with the navbar-right class.

    Style The Navbar

    Use CSS to customize the navigation bar:

    Example

    .navbar { margin-bottom: 0; background-color: #f4511e; z-index: 9999; border: 0; font-size: 12px !important; line-height: 1.42857143 !important; letter-spacing: 4px; border-radius: 0; } .navbar li a, .navbar .navbar-brand { color: #fff !important; } .navbar-nav li a:hover, .navbar-nav li.active a { color: #f4511e !important; background-color: #fff !important; } .navbar-default .navbar-toggle { border-color: transparent; color: #fff !important; } Result: Try it Yourself »

    Add Scrollspy

    Add scrollspy to automatically update navbar links when scrolling:

    Example

    <body id="myPage" data-spy="scroll" data-target=".navbar" data-offset="60"> <div id="about" class="container-fluid"> <div id="services" class="container-fluid"> <div id="portfolio" class="container-fluid"> <div id="pricing" class="container-fluid"> <div id="contact" class="container-fluid"> Try it Yourself »

    Add a Footer

    Add an "Up Arrow" icon to the footer, which will take the user to the top of the page when clicked on:

    Example

    <style> footer .glyphicon { font-size: 20px; margin-bottom: 20px; color: #f4511e; } </style> <footer class="container-fluid text-center"> <a href="#myPage" title="To Top"> <span class="glyphicon glyphicon-chevron-up"></span> </a> <p>Bootstrap Theme Made By <a href="https://www.w3schools.com" title="Visit w3schools">www.w3schools.com</a></p> </footer> Result: Try it Yourself »

    Adding Smooth Scrolling

    Use jQuery to add smooth scrolling (when clicking on the links in the navbar):

    Example

    <script> $(document).ready(function(){ // Add smooth scrolling to all links in navbar + footer link $(".navbar a, footer a[href='#myPage']").on('click', function(event) { // Make sure this.hash has a value before overriding default behavior if (this.hash !== ") { // Prevent default anchor click behavior event.preventDefault(); // Store hash var hash = this.hash; // Using jQuery's animate() method to add smooth page scroll // The optional number (900) specifies the number of milliseconds it takes to scroll to the specified area $('html, body').animate({ scrollTop: $(hash).offset().top }, 900, function(){ // Add hash (#) to URL when done scrolling (default click behavior) window.location.hash = hash; }); } // End if }); }) </script> Try it Yourself »

    Final Touch

    Personalize your Theme by adding a font that you like. We have used "Montserrat" and "Lato" from Google's Font Library. Link to the font in the <head> section: <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css"> Then you can use them in the page:

    Example

    body { font: 400 15px Lato, sans-serif; line-height: 1.8; color: #818181; } .jumbotron { font-family: Montserrat, sans-serif; } .navbar { font-family: Montserrat, sans-serif; } We have also added some extra style to some elements:

    Example

    h2 { font-size: 24px; text-transform: uppercase; color: #303030; font-weight: 600; margin-bottom: 30px; } h4 { font-size: 19px; line-height: 1.375em; color: #303030; font-weight: 400; margin-bottom: 30px; } Try it Yourself »

    Slide In Elements

    We have also created an animation effect which will slide in elements on scroll. If you want to use it, just add the .slideanim class to the element you want to slide in, and add the following to your CSS and jQuery (feel free to modify the duration, opacity, where to start, when to slide in, and so on):

    CSS Example

    .slideanim {visibility:hidden;} .slide { /* The name of the animation */ animation-name: slide; -webkit-animation-name: slide; /* The duration of the animation */ animation-duration: 1s; -webkit-animation-duration: 1s; /* Make the element visible */ visibility: visible; } /* Go from 0% to 100% opacity (see-through) and specify the percentage from when to slide in the element along the Y-axis */ @keyframes slide { 0% { opacity: 0; transform: translateY(70%); } 100% { opacity: 1; transform: translateY(0%); } } @-webkit-keyframes slide { 0% { opacity: 0; -webkit-transform: translateY(70%); } 100% { opacity: 1; -webkit-transform: translateY(0%); } }

    jQuery Example

    $(window).scroll(function() { $(".slideanim").each(function(){ var pos = $(this).offset().top; var winTop = $(window).scrollTop(); if (pos < winTop + 600) { $(this).addClass("slide"); } }); }); Try it Yourself »

    Complete "Company" Theme

    Full Page Demo Full Source Code

    Bootstrap Theme "The Band"

    Create a Theme: "The Band"

    This page will show you how to build a Bootstrap theme from scratch. We will start with a simple HTML page, and then add more and more components, until we have a fully functional, personal and responsive website. The result will look like this, and you are free to modify, save, share, use or do whatever you want with it: Full Page Demo Full Source Code We will start with the following HTML page: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Theme The Band</title> <meta charset="utf-8"> </head> <body> <div> <h3>THE BAND</h3> <p>We love music!</p> <p>We have created a fictional band website. Lorem ipsum..</p> </div> </body> </html>

    Add Bootstrap CDN and Add a Container

    Add Bootstrap CDN and a link to jQuery and put HTML elements inside a container (.container):

    Example

    <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Theme The Band</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h3>THE BAND</h3> <p>We love music!</p> <p>We have created a fictional band website. Lorem ipsum..</p> </div> </body> </html> Result:

    THE BAND

    We love music! We have created a fictional band website. Lorem ipsum.. Try it Yourself »

    Center Text

    Add the .text-center class to center the text inside the container, and use the <em> element to make the "We love music" text italic:

    Example

    <div class="container text-center"> <h3>THE BAND</h3> <p><em>We love music!</em></p> <p>We have created a fictional band website. Lorem ipsum..</p> </div> Result:

    THE BAND

    We love music! We have created a fictional band website. Lorem ipsum.. Try it Yourself »

    Add Padding

    Use CSS to make the container look good with padding:

    Example

    .container { padding: 80px 120px; } Result:

    THE BAND

    We love music! We have created a fictional band website. Lorem ipsum.. Try it Yourself »

    Add a Grid

    Create three columns of equal width (.col-sm-4), add text and images, and put them inside the container:

    Example

    <div class="container text-center"> <h3>THE BAND</h3> <p><em>We love music!</em></p> <p>We have created a fictional band website. Lorem ipsum..</p> <br> <div class="row"> <div class="col-sm-4"> <p><strong>Name</strong></p><br> <img src="bandmember.jpg" alt="Random Name"> </div> <div class="col-sm-4"> <p><strong>Name</strong></p><br> <img src="bandmember.jpg" alt="Random Name"> </div> <div class="col-sm-4"> <p><strong>Name</strong></p><br> <img src="bandmember.jpg" alt="Random Name"> </div> </div> </div> Result:

    THE BAND

    We love music! We have created a fictional band website. Lorem ipsum.. Name Name Name Try it Yourself »

    Circle Image

    Shape the image to a circle with the .img-circle class. We have also added some CSS to make the images look good:

    Example

    .person { border: 10px solid transparent; margin-bottom: 25px; width: 80%; height: 80%; opacity: 0.7; } .person:hover { border-color: #f1f1f1; } <img src="bandmember.jpg" class="img-circle person" alt="Random Name"> <img src="bandmember.jpg" class="img-circle person" alt="Random Name"> <img src="bandmember.jpg" class="img-circle person" alt="Random Name"> Result: Name Random Name Name Random Name Name Random Name Try it Yourself »

    Collapsibles

    Make the images collapsible; show extra content when you click on each image:

    Example

    <div class="row"> <div class="col-sm-4"> <p class="text-center"><strong>Name</strong></p><br> <a href="#demo" data-toggle="collapse"> <img src="bandmember.jpg" class="img-circle person" alt="Random Name"> </a> <div id="demo" class="collapse"> <p>Guitarist and Lead Vocalist</p> <p>Loves long walks on the beach</p> <p>Member since 1988</p> </div> </div> <div class="col-sm-4"> <p class="text-center"><strong>Name</strong></p><br> <a href="#demo2" data-toggle="collapse"> <img src="bandmember.jpg" class="img-circle person" alt="Random Name"> </a> <div id="demo2" class="collapse"> <p>Drummer</p> <p>Loves drummin'</p> <p>Member since 1988</p> </div> </div> <div class="col-sm-4"> <p class="text-center"><strong>Name</strong></p><br> <a href="#demo3" data-toggle="collapse"> <img src="bandmember.jpg" class="img-circle person" alt="Random Name"> </a> <div id="demo3" class="collapse"> <p>Bass player</p> <p>Loves math</p> <p>Member since 2005</p> </div> </div> </div> Result (click on the images to see the effect): Name Random Name Guitarist and Lead Vocalist Loves long walks on the beach Member since 1988 Name Random Name Drummer Loves drummin' Member since 1988 Name Random Name Bass player Loves math Member since 2005 Try it Yourself »

    Add a Carousel

    Create a carousel and add it before the container:

    Example

    <div id="myCarousel" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#myCarousel" data-slide-to="0" class="active"></li> <li data-target="#myCarousel" data-slide-to="1"></li> <li data-target="#myCarousel" data-slide-to="2"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="ny.jpg" alt="New York"> <div class="carousel-caption"> <h3>New York</h3> <p>The atmosphere in New York is lorem ipsum.</p> </div> </div> <div class="item"> <img src="chicago.jpg" alt="Chicago"> <div class="carousel-caption"> <h3>Chicago</h3> <p>Thank you, Chicago - A night we won't forget.</p> </div> </div> <div class="item"> <img src="la.jpg" alt="Los Angeles"> <div class="carousel-caption"> <h3>LA</h3> <p>Even though the traffic was a mess, we had the best time.</p> </div> </div> </div> <!-- Left and right controls --> <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> Result:

    New York

    The atmosphere in New York is lorem ipsum.

    Chicago

    Thank you, Chicago - A night we won't forget.

    LA

    Even though the traffic was a mess, we had the best time playing at Venice Beach! Previous Next Try it Yourself »

    Style The Carousel

    Use CSS to style the carousel:

    Example

    .carousel-inner img { -webkit-filter: grayscale(90%); filter: grayscale(90%); /* make all photos black and white */ width: 100%; /* Set width to 100% */ margin: auto; } .carousel-caption h3 { color: #fff !important; } @media (max-width: 600px) { .carousel-caption { display: none; /* Hide the carousel text when the screen is less than 600 pixels wide */ } } Result:

    New York

    The atmosphere in New York is lorem ipsum.

    Chicago

    Thank you, Chicago - A night we won't forget.

    LA

    Even though the traffic was a mess, we had the best time playing at Venice Beach! Previous Next Try it Yourself »

    Add Tour Container

    Add a new container and add a list (.list-group and .list-group-item) inside of it. Add a custom class (.bg-1) to the container (black background color) and some styles to its children:

    Example

    <style> .bg-1 { background: #2d2d30; color: #bdbdbd; } .bg-1 h3 {color: #fff;} .bg-1 p {font-style: italic;} </style> <div class="bg-1"> <div class="container"> <h3 class="text-center">TOUR DATES</h3> <p class="text-center">Lorem ipsum we'll play you some music.<br> Remember to book your tickets!</p> <ul class="list-group"> <li class="list-group-item">September Sold Out!</li> <li class="list-group-item">October Sold Out!</li> <li class="list-group-item">November 3</li> </ul> </div> </div> Result:

    TOUR DATES

    Lorem ipsum we'll play you some music. Remember to book your tickets!
  • September Sold Out!
  • October Sold Out!
  • November 3
  • Try it Yourself »

    Add Labels & Badges

    Add a label (.label) and a badge (.badge) to highlight available tickets/sold out:

    Example

    <ul class="list-group"> <li class="list-group-item">September <span class="label label-danger">Sold Out!</span></li> <li class="list-group-item">October <span class="label label-danger">Sold Out!</span></li> <li class="list-group-item">November <span class="badge">3</span></li> </ul> Result:

    TOUR DATES

    Lorem ipsum we'll play you some music. Remember to book your tickets!
  • September Sold Out!
  • October Sold Out!
  • November 3
  • Try it Yourself »

    Add Thumbnail Images

    Inside the Tour container, add three columns of equal width (.col-sm-4): Inside each column, add an image. Then, use the .img-thumbnail class to shape the image to a thumbnail. Normally, you would add the .img-thumbnail class directly to the <img> element. In this example, we have placed a thumbnail container around the image, so that we can specify an image text as well.

    Example

    <div class="row text-center"> <div class="col-sm-4"> <div class="thumbnail"> <img src="paris.jpg" alt="Paris"> <p><strong>Paris</strong></p> <p>Fri. 27 November 2015</p> <button class="btn">Buy Tickets</button> </div> </div> <div class="col-sm-4"> <div class="thumbnail"> <img src="newyork.jpg" alt="New York"> <p><strong>New York</strong></p> <p>Sat. 28 November 2015</p> <button class="btn">Buy Tickets</button> </div> </div> <div class="col-sm-4"> <div class="thumbnail"> <img src="sanfran.jpg" alt="San Francisco"> <p><strong>San Francisco</strong></p> <p>Sun. 29 November 2015</p> <button class="btn">Buy Tickets</button> </div> </div> </div> Result: Paris Fri. 27 November 2015 New York Sat. 28 November 2015 San Francisco Sun. 29 November 2015 Try it Yourself »

    Style Lists, Thumbnails & Buttons

    Use CSS to style the list and the thumbnail images. In our example, we have removed the rounded borders from the list and we have tried to make the thumbnail images like cards, by removing their border, and set a 100% width on each image. We have also modified the default styles of Bootstrap's .btn class, to a black button:

    Example

    /* Remove rounded borders from list */ .list-group-item:first-child { border-top-right-radius: 0; border-top-left-radius: 0; } .list-group-item:last-child { border-bottom-right-radius: 0; border-bottom-left-radius: 0; } /* Remove border and add padding to thumbnails */ .thumbnail { padding: 0 0 15px 0; border: none; border-radius: 0; } .thumbnail p { margin-top: 15px; color: #555; } /* Black buttons with extra padding and without rounded borders */ .btn { padding: 10px 20px; background-color: #333; color: #f1f1f1; border-radius: 0; transition: .2s; } /* On hover, the color of .btn will transition to white with black text */ .btn:hover, .btn:focus { border: 1px solid #333; background-color: #fff; color: #000; } Result:
  • September Sold Out!
  • October Sold Out!
  • November 3
  • Paris Fri. 27 November 2015 New York Sat. 28 November 2015 San Francisco Sun. 29 November 2015 Try it Yourself »

    Add a Modal

    First, change all buttons inside the thumbnail from <button class="btn">Buy Tickets</button> to <button class="btn" data-toggle="modal" data-target="#myModal" >Buy Tickets</button>. These buttons are used to open the actual modal. To create the modal, look at the following code:

    Example

    <style> /* Add a dark gray background color to the modal header and center text */ .modal-header, h4, .close { background-color: #333; color: #fff !important; text-align: center; font-size: 30px; } .modal-header, .modal-body { padding: 40px 50px; } </style> <!-- Used to open the Modal --> <button class="btn" data-toggle="modal" data-target="#myModal">Buy Tickets</button> <!-- Modal --> <div class="modal fade" id="myModal" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4><span class="glyphicon glyphicon-lock"></span> Tickets</h4> </div> <div class="modal-body"> <form role="form"> <div class="form-group"> <label for="psw"><span class="glyphicon glyphicon-shopping-cart"></span> Tickets, $23 per person</label> <input type="number" class="form-control" id="psw" placeholder="How many?"> </div> <div class="form-group"> <label for="usrname"><span class="glyphicon glyphicon-user"></span> Send To</label> <input type="text" class="form-control" id="usrname" placeholder="Enter email"> </div> <button type="submit" class="btn btn-block">Pay <span class="glyphicon glyphicon-ok"></span> </button> </form> </div> <div class="modal-footer"> <button type="submit" class="btn btn-danger btn-default pull-left" data-dismiss="modal"> <span class="glyphicon glyphicon-remove"></span> Cancel </button> <p>Need <a href="#">help?</a></p> </div> </div> </div> </div> Result (click on the "Buy Tickets" button to see the effect):

    Tickets

    Need help? Try it Yourself »

    Add Contact Container

    Create a new container, with two columns of unequal width (.col-md-4 and .col-md-8). Add informational icons with text inside the first column and form controls in the second:

    Example

    <div class="container"> <h3 class="text-center">Contact</h3> <p class="text-center"><em>We love our fans!</em></p> <div class="row test"> <div class="col-md-4"> <p>Fan? Drop a note.</p> <p><span class="glyphicon glyphicon-map-marker"></span>Chicago, US</p> <p><span class="glyphicon glyphicon-phone"></span>Phone: +00 1515151515</p> <p><span class="glyphicon glyphicon-envelope"></span>Email: mail@mail.com</p> </div> <div class="col-md-8"> <div class="row"> <div class="col-sm-6 form-group"> <input class="form-control" id="name" name="name" placeholder="Name" type="text" required> </div> <div class="col-sm-6 form-group"> <input class="form-control" id="email" name="email" placeholder="Email" type="email" required> </div> </div> <textarea class="form-control" id="comments" name="comments" placeholder="Comment" rows="5"></textarea> <div class="row"> <div class="col-md-12 form-group"> <button class="btn pull-right" type="submit">Send</button> </div> </div> </div> </div> </div> Result:

    Contact

    We love our fans! Fan? Drop a note. Chicago, US Phone: +00 1515151515 Email: mail@mail.com Try it Yourself »

    Add Toggable Tabs

    Add tabs (.nav nav-tabs) inside the contact container, with "quotes" from the band members:

    Example

    <style> .nav-tabs li a { color: #777; } </style> <h3 class="text-center">From The Blog</h3> <ul class="nav nav-tabs"> <li class="active"><a data-toggle="tab" href="#home">Mike</a></li> <li><a data-toggle="tab" href="#menu1">Chandler</a></li> <li><a data-toggle="tab" href="#menu2">Peter</a></li> </ul> <div class="tab-content"> <div id="home" class="tab-pane fade in active"> <h2>Mike Ross, Manager</h2> <p>Man, we've been on the road for some time now. Looking forward to lorem ipsum.</p> </div> <div id="menu1" class="tab-pane fade"> <h2>Chandler Bing, Guitarist</h2> <p>Always a pleasure people! Hope you enjoyed it as much as I did. Could I BE.. any more pleased?</p> </div> <div id="menu2" class="tab-pane fade"> <h2>Peter Griffin, Bass player</h2> <p>I mean, sometimes I enjoy the show, but other times I enjoy other things.</p> </div> </div> Result:

    From The Blog

  • Mike
  • Chandler
  • Peter
  • Mike Ross, Manager

    Man, we've been on the road for some time now. Looking forward to lorem ipsum.

    Chandler Bing, Guitarist

    Always a pleasure people! Hope you enjoyed it as much as I did. Could I BE.. any more pleased?

    Peter Griffin, Bass player

    I mean, sometimes I enjoy the show, but other times I enjoy other things. Try it Yourself »

    Add Map/Location Image

    Add a location image or a map (read our Google Maps Tutorial for google maps):

    Example

    <!-- Image of location/map --> <img src="map.jpg" style="width:100%"> Result: Try it Yourself »

    Add a Navbar

    Add a navbar at the top of the page that collapses on smaller screens:

    Example

    <nav class="navbar navbar-default navbar-fixed-top"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Logo</a> </div> <div class="collapse navbar-collapse" id="myNavbar"> <ul class="nav navbar-nav navbar-right"> <li><a href="#home">HOME</a></li> <li><a href="#band">BAND</a></li> <li><a href="#tour">TOUR</a></li> <li><a href="#contact">CONTACT</a></li> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">MORE <span class="caret"></span> </a> <ul class="dropdown-menu"> <li><a href="#">Merchandise</a></li> <li><a href="#">Extras</a></li> <li><a href="#">Media</a></li> </ul> </li> <li><a href="#"><span class="glyphicon glyphicon-search"></span></a></li> </ul> </div> </div> </nav> Result: Try it Yourself » Tip: Right-align the navigation links with the navbar-right class. If you want one of the links in the navbar to behave like a dropdown menu, use the .dropdown class

    Style The Navbar

    Use CSS to customize the navigation bar:

    Example

    /* Add a dark background color with a little bit see-through */ .navbar { margin-bottom: 0; background-color: #2d2d30; border: 0; font-size: 11px !important; letter-spacing: 4px; opacity: 0.9; } /* Add a gray color to all navbar links */ .navbar li a, .navbar .navbar-brand { color: #d5d5d5 !important; } /* On hover, the links will turn white */ .navbar-nav li a:hover { color: #fff !important; } /* The active link */ .navbar-nav li.active a { color: #fff !important; background-color:#29292c !important; } /* Remove border color from the collapsible button */ .navbar-default .navbar-toggle { border-color: transparent; } /* Dropdown */ .open .dropdown-toggle { color: #fff ; background-color: #555 !important; } /* Dropdown links */ .dropdown-menu li a { color: #000 !important; } /* On hover, the dropdown links will turn red */ .dropdown-menu li a:hover { background-color: red !important; } Result: Try it Yourself »

    Add Scrollspy

    Add scrollspy to automatically update navbar links when scrolling:

    Example

    <body id="myPage" data-spy="scroll" data-target=".navbar" data-offset="50"> <div id="band" class="container"> <div id="tour" class="container"> <div id="contact" class="container"> Try it Yourself »

    Add a Footer

    1. Create a <footer> element and add some text. 2. Use CSS to style the footer. 3. Add an "Up Arrow" icon, which will take the user to the top of the page when clicked on. 4. Use jQuery to initialize the tooltip plugin:

    Example

    <style> /* Add a dark background color to the footer */ footer { background-color: #2d2d30; color: #f5f5f5; padding: 32px; } footer a { color: #f5f5f5; } footer a:hover { color: #777; text-decoration: none; } </style> <footer class="text-center"> <a class="up-arrow" href="#myPage" data-toggle="tooltip" title="TO TOP"> <span class="glyphicon glyphicon-chevron-up"></span> </a><br><br> <p>Bootstrap Theme Made By <a href="https://www.w3schools.com" data-toggle="tooltip" title="Visit w3schools">www.w3schools.com</a></p> </footer> <script> $(document).ready(function(){ // Initialize Tooltip $('[data-toggle="tooltip"]').tooltip(); }) </script> Result: Try it Yourself »

    Adding Smooth Scrolling

    Use jQuery to add smooth scrolling (when clicking on the links in the navbar):

    Example

    <script> $(document).ready(function(){ // Add smooth scrolling to all links in navbar + footer link $(".navbar a, footer a[href='#myPage']").on('click', function(event) { // Make sure this.hash has a value before overriding default behavior if (this.hash !== ") { // Prevent default anchor click behavior event.preventDefault(); // Store hash var hash = this.hash; // Using jQuery's animate() method to add smooth page scroll // The optional number (900) specifies the number of milliseconds it takes to scroll to the specified area $('html, body').animate({ scrollTop: $(hash).offset().top }, 900, function(){ // Add hash (#) to URL when done scrolling (default click behavior) window.location.hash = hash; }); } // End if }); }) </script> Try it Yourself »

    Final Touch

    Personalize your Theme by adding a font that you like. We have used "Montserrat" and "Lato" from Google's Font Library. Link to the font in the <head> section: <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css"> Then you can use them in the page:

    Example

    body { font: 400 15px/1.8 Lato, sans-serif; color: #777; } .navbar { font-family: Montserrat, sans-serif; } We have also added some extra style to some elements:

    Example

    /* Overwrite default styles of h3 and h4 */ h3, h4 { margin: 10px 0 30px 0; letter-spacing: 10px; font-size: 20px; color: #111; } /* Remove rounded borders on input fields */ .form-control { border-radius: 0; } /* Disable the ability to resize textareas */ textarea { resize: none; } Try it Yourself »

    Complete "The Band" Theme

    Full Page Demo Full Source Code

    Bootstrap Examples

    Bootstrap Get Started

    Container Fluid container Examples explained

    Bootstrap Grid Basic

    Three equal columns Two unequal columns Examples explained

    Bootstrap Typography

    Headings <h1> to <h6> The <small> element The <mark> element The <abbr> element The <blockquote> element Reversed blockquote The <dl> element The <code> element The <kbd> element The <pre> element Contextual text colors Contextual background colors Examples explained

    Bootstrap Tables

    Basic table Striped rows Bordered table Hover rows Condensed table Contextual classes Responsive tables Examples explained

    Bootstrap Images

    Rounded image Circle image Thumbnail image Responsive images Image gallery Responsive embeds Examples explained

    Bootstrap Jumbotron

    Jumbotron inside container Jumbotron outside container Creating a page header Examples explained

    Bootstrap Wells

    Basic well Well size Examples explained

    Bootstrap Alerts

    Alerts Closing alerts Animated alerts Examples explained

    Bootstrap Buttons

    Button styles Button tags Button sizes Block level buttons Active/disabled buttons Examples explained

    Bootstrap Button Groups

    Button group Button group sizes Vertical button group Justified button group Justified button group 2 Nesting button groups and dropdown menus Split buttons Examples explained

    Bootstrap Glyphicons

    Glyphicons Examples explained

    Bootstrap Badges and Labels

    Badges Badge inside a button Labels Contextual labels Examples explained

    Bootstrap Progress Bars

    Progress bar Progress bar with label Colored progress bar Striped progress bar Animated progress bar Stacked progress bar Examples explained

    Bootstrap Pagination

    Pagination Active pagination link Disabled pagination link Pagination sizing Breadcrumbs Examples explained

    Bootstrap Pager

    Pager Align buttons Examples explained

    Bootstrap List Groups

    List group List group with badges List group with links Active list item Disabled list item Contextual classes Custom content Examples explained

    Bootstrap Panels

    Panels Panel heading Panel footer Panel group Contextual panel classes Examples explained

    Bootstrap Dropdowns

    Dropdown Dropdown divider Dropdown header Disabled dropdown item Right-aligned dropdown menu Dropup Dropdown accessibility Examples explained

    Bootstrap Collapsible

    Collapsible button Collapsible link Collapsible "in" (show by default) Collapsible panel Collapsible list group Accordion Examples explained

    Bootstrap Tabs and Pills

    Inline list Tabs Tabs with dropdown menu Pills Vertical pills Vertical pills in a row Pills with dropdown menu Centered tabs and pills Toggleable/dynamic tabs Toggleable/dynamic pills Examples explained

    Bootstrap Navbar

    Navbar Inverted navbar Fixed top navbar Fixed bottom navbar Navbar with dropdown Right-aligned navbar Collapsible navbar Examples explained

    Bootstrap Forms

    Vertical form Inline form Inline form without labels Horizontal form Examples explained

    Bootstrap Inputs

    Input Textarea Checkbox Inline checkbox Radio buttons Inline radio buttons Select menu Examples explained

    Bootstrap Inputs 2

    Static control Control states Inline form: control states Examples explained

    Bootstrap Input Sizing

    Input sizing Input sizing horizontal label Input width (columns) Input help text Examples explained

    Bootstrap Media Objects

    Left and right-aligned media object Top, middle and bottom-aligned media object Nested media object Nested media object II Examples explained

    Bootstrap Carousel

    Carousel Caption slides Examples explained

    Bootstrap Modal

    Modal Small modal Large modal Examples explained

    Bootstrap Tooltip

    Tooltip Positioning tooltips Examples explained

    Bootstrap Popover

    Popover Positioning popovers Dismissable popover Hoverable popover Examples explained

    Bootstrap Scrollspy

    Horizontal scrollspy Vertical scrollspy Examples explained

    Bootstrap Affix

    Horizontal affix Vertical affix Scrollspy and affix (horizontal) Scrollspy and affix (vertical) Examples explained

    Bootstrap Filters

    Filter table Filter list Filter dropdown Filter anything Examples explained

    Bootstrap Grid: Stacked to Horizontal

    Stacked to horizontal grid Stacked to horizontal grid with fluid container Examples explained

    Bootstrap Grid: Small Devices

    Small grid Small grid Examples explained

    Bootstrap Grid: Medium Devices

    Medium grid Medium grid 2 Examples explained

    Bootstrap Grid: Large Devices

    Medium grid Medium grid 2 Examples explained

    Bootstrap Grid Examples

    Three equal columns Three unequal columns Two unequal columns Two columns with two nested columns Mixed columns: mobile and desktop Mixed columns: mobile, tablet and desktop Clear floats Offsetting columns Push and Pull - Change column order Examples explained

    Bootstrap Quiz

    You can test your Bootstrap skills with W3Schools' Quiz.

    The Test

    The test contains 25 questions and there is no time limit. The test is not official, it's just a nice way to see how much you know, or don't know, about Bootstrap.

    Count Your Score

    You will get 1 point for each correct answer. At the end of the Quiz, your total score will be displayed. Maximum score is 25 points.

    Start the Quiz

    Good luck! Start the Bootstrap Quiz ❯ If you don't know Bootstrap, we suggest that you read our Bootstrap Tutorial from scratch. W3Schools Certification

    W3Schools' Online Certification

    The perfect solution for professionals who need to balance work, family, and career building. More than 25 000 certificates already issued! Get Your Certificate » The HTML Certificate documents your knowledge of HTML. The CSS Certificate documents your knowledge of advanced CSS. The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM. The Python Certificate documents your knowledge of Python. The jQuery Certificate documents your knowledge of jQuery. The SQL Certificate documents your knowledge of SQL. The PHP Certificate documents your knowledge of PHP and MySQL. The XML Certificate documents your knowledge of XML, XML DOM and XSLT. The Bootstrap Certificate documents your knowledge of the Bootstrap framework.

    Bootstrap 3 Exercises

    You can test your Bootstrap 3 skills with W3Schools' Exercises.

    Exercises

    We have gathered a variety of Bootstrap 3 exercises (with answers) for each Bootstrap 3 Chapter. Try to solve an exercise by filling in the missing parts of a code. If your stuck, hit the "Show Answer" button to see what you've done wrong.

    Count Your Score

    You will get 1 point for each correct answer. Your score and total score will always be displayed.

    Start Bootstrap 3 Exercises

    Good luck! Start Bootstrap 3 Exercises ❯ If you don't know Bootstrap 3, we suggest that you read our Bootstrap 3 Tutorial from scratch. W3Schools Certification

    W3Schools' Online Certification

    The perfect solution for professionals who need to balance work, family, and career building. More than 25 000 certificates already issued! Get Your Certificate » The HTML Certificate documents your knowledge of HTML. The CSS Certificate documents your knowledge of advanced CSS. The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM. The Python Certificate documents your knowledge of Python. The jQuery Certificate documents your knowledge of jQuery. The SQL Certificate documents your knowledge of SQL. The PHP Certificate documents your knowledge of PHP and MySQL. The XML Certificate documents your knowledge of XML, XML DOM and XSLT. The Bootstrap Certificate documents your knowledge of the Bootstrap framework.

    W3Schools Bootstrap Certificate

    W3Schools Certified W3Schools offers an Online Certification Program. The perfect solution for busy professionals who need to balance work, family, and career building. More than 25 000 certificates already issued!

    Document Your Skills

    Knowledge is power, especially in the current job market. Documentation of your skills enables you to advance your career, or help you to start a new one.

    Get a Certificate

    Getting a certificate proves your commitment to upgrade your skills, gives you the credibility needed for more responsibilities, larger projects, and a higher salary. Get Your Certificate »
    W3Schools Certificate

    How Does It Work?

  • Study for free at W3Schools.com
  • Study at your own speed
  • Test your skills with W3Schools online quizzes
  • Apply for your certificate by paying an exam fee
  • Take your exam online, at any time, and from any location
  • Bootstrap Classes Reference

    Complete List of All Bootstrap Classes

    Complete list of all Bootstrap classes with description and examples:
    Class DescriptionExampleCategory
    .active Adds a grey background color to the table row (<tr> or table cell (<td>) (same color used on hover) Try it Tables
    .active Adds a gray background color to the active link in a default navbar. Adds a black background and a white color to the current link inside an inverted navbar. Try it Navbar
    .active Adds a blue background color to the active list item in a list group Try it List Groups
    .active Adds a blue background color to simulate a "pressed" button Try it Buttons
    .active Animates a striped progress bar Try it Progress Bars
    .active Adds a blue background color to the active dropdown item in a dropdown Try it Dropdowns
    .active Adds a blue background color to the active pagination link (to highlight the current page) Try it Pagination
    .affix The Affix plugin allows an element to become affixed (locked/sticky) to an area on the page. It toggles position:fixed on and off Try it Affix
    .alert Creates an alert message box Try it Alerts
    .alert-danger Red alert box. Indicates a dangerous or potentially negative action Try it Alerts
    .alert-dismissible Together with the .close class, this class is used to close the alert Try it Alerts
    .alert-info Light-blue alert box. Indicates some information Try it Alerts
    .alert-link Used on links inside alerts to add matching colored links Try it Alerts
    .alert-success Green alert box. Indicates a successful or positive action Try it Alerts
    .alert-warning Yellow alert box. Indicates caution should be taken with this action Try it Alerts
    .badge Creates a circular badge (grey circle - often used as a numerical indicator) Try it Badges
    .bg-danger Adds a red background color to an element. Represents danger or a negative action Try it Helpers
    .bg-info Adds a light-blue background color to an element. Represents some information Try it Helpers
    .bg-primary Adds a blue background color to an element. Represents something important Try it Helpers
    .bg-success Adds a green background color to an element. Indicates success or a positive action Try it Helpers
    .bg-warning Adds a yellow background color to an element. Represents a warning or a negative action Try it Helpers
    .breadcrumb A pagination. Indicates the current page's location within a navigational hierarchy Try it Pagination
    .btn Creates a basic button (gray background and rounded corners) Try it Buttons
    .btn-block Creates a block level button that spans the entire width of the parent element Try it Buttons
    .btn-danger Red button. Indicates danger or a negative action Try it Buttons
    .btn-default Default button. White background and grey border Try it Buttons
    .btn-group Groups buttons together on a single line Try it Button Groups
    .btn-group-justified Makes a group of buttons span the entire width of the screen Try it Button Groups
    .btn-group-lg Large button group (makes all buttons in a button group larger - increased font-size and padding) Try it Button Groups
    .btn-group-sm Small button group (makes all buttons in a button group smaller) Try it Button Groups
    .btn-group-xs Extra small button group (makes all buttons in a button group extra small) Try it Button Groups
    .btn-group-vertical Makes a button group appear vertically stacked Try it Button Groups
    .btn-info Light-blue button. Represents information Try it Buttons
    .btn-link Makes a button look like a link (get button behavior) Try it Buttons
    .btn-lg Large button Try it Buttons
    .btn-primary Blue button. Try it Buttons
    .btn-sm Small button Try it Buttons
    .btn-success Green button. Indicates success or a positive action Try it Buttons
    .btn-warning Yellow button. Represents warning or a negative action Try it Buttons
    .btn-xs Extra small button Try it Buttons
    .caption Adds a caption text inside a .thumbnail Try it Images
    .caret Creates a caret arrow icon , which indicates that the button is a dropdown Try it Dropdowns
    .carousel Creates a carousel (slideshow) Try it Carousel
    .carousel-caption Creates a caption text for each slide in the carousel Try it Carousel
    .carousel-control Container for next and previous links Try it Carousel
    .carousel-indicators Adds little dots/indicators at the bottom of each slide (which indicates how many slides there is in the carousel, and which slide the user are currently viewing) Try it Carousel
    .carousel-inner Container for slide items Try it Carousel
    .center-block Centers any element (Sets an element to display:block with margin-right:auto and margin-left:auto) Try it Helpers
    .checkbox Container for checkboxes Try it Inputs
    .checkbox-inline Makes multiple checkboxes appear on the same line Try it Inputs
    .clearfix Clears floats Try it Helpers
    .close Indicates a close icon Try it Helpers
    .col-*-* Responsive grid (span 1-12 column). Extra small devices Phones (< 768px), Small devices Tablets (≥768px), Medium devices Desktops (≥992px), Large devices Desktops (≥1200px). Column values can be 1-12. Try it Grid
    .col-*-offset-* Move columns to the right. These classes increase the left margin of a column by * columns Try it Grid
    .col-*-pull-* Changes the order of the grid columns Try it Grid
    .col-*-push-* Changes the order of the grid columns Try it Grid
    .collapse Indicates collapsible content - which can be hidden or shown on demand Try it Collapse
    .collapse in Show the collapsible content by default Try it Collapse
    .container Fixed width container with widths determined by screen sites. Equal margin on the left and right. Try it Containers
    .container-fluid A container that spans the full width of the screen Try it Containers
    .control-label Allows a label to be used for form validation Try it Forms
    .danger Adds a red background to the table row (<tr> or table cell (<td>). Indicates a dangerous or potentially negative action Try it Tables
    .disabled Disables a button (adds opacity and a "no-parking-sign" icon on hover) Try it Buttons
    .disabled Disables a dropdown item (adds a grey text color and a "no-parking-sign" icon on hover) Try it Dropdowns
    .disabled Disables a pagination link (cannot be clicked - adds a grey text color and a "no-parking-sign" icon on hover) Try it Pagination
    .disabled Disables a list item in a list group (cannot be clicked - adds a grey background color and a "no-parking-sign" icon on hover) Try it List Groups
    .divider Used to separate links in the dropdown menu with a thin horizontal border Try it Dropdowns
    .dl-horizontal Lines up the terms <dt> and descriptions <dd> in <dl> elements side-by-side. Starts off like default <dl>s, but when the browser window expands, it will line up side-by-side Try it Typography
    .dropdown Creates a toggleable menu that allows the user to choose one value from a predefined list Try it Dropdowns
    .dropdown-header Used to add headers inside the dropdown menu Try it Dropdowns
    .dropdown-menu Adds the default styles for the dropdown menu container Try it Dropdowns
    .dropdown-menu-right Right-aligns a dropdown menu Try it Dropdowns
    .dropdown-toggle Used on the button that should hide and show (toggle) the dropdown menu Try it Dropdowns
    .dropup Indicates a dropup menu (upwards instead of downwards) Try it Dropdowns
    .embed-responsive Container for embedded content. Makes videos or slideshows scale properly on any device Try it Images
    .embed-responsive-16by9 Container for embedded content. Creates an 16:9 aspect ratio embedded content Try it Images
    .embed-responsive-4by3 Container for embedded content. Creates an 4:3 aspect ratio embedded content Try it Images
    .embed-responsive-item Used inside .embed-responsive. Scales the video nicely to the parent element Try it Images
    .fade Adds a fading effect when closing an alert box Try it Alerts
    .form-control Used on input, textarea, and select elements to span the entire width of the page and make them responsive Try it Forms
    .form-control-feedback Form validation class Try it Inputs 2
    .form-control-static Adds plain text next to a form label within a horizontal form Try it Inputs 2
    .form-group Container for form input and label Try it Forms
    .form-inline Makes a <form> left-aligned with inline-block controls (This only applies to forms within viewports that are at least 768px wide) Try it Forms
    .form-horizontal Aligns labels and groups of form controls in a horizontal layout Try it Forms
    .glyphicon Creates an icon. Bootstrap provides 260 free glyphicons from the Glyphicons Halflings set Try it Glyphicons
    .has-danger Adds a red color to the label and a red border to the input, as well as an error icon inside the input (used together with .has-feedback) Try it Forms
    .has-feedback Adds feedback icons for inputs (checkmark, warning and error signs) Try it Forms
    .has-success Adds a green color to the label and a green border to the input, as well as a checkmark icon inside the input (used together with .has-feedback) Try it Forms
    .has-warning Adds a yellow/orange color to the label and a yellow/orange border to the input, as well as a checkmark icon inside the input (used together with .has-feedback) Try it Forms
    .help-block A block of help text that breaks onto a new line and may extend beyond one line. Try it Input Sizing
    .hidden Forces an element to be hidden (display:none) Try it Helpers
    .hidden-* Hides content depending on screen size Try it Helpers
    .hide Deprecated. Use .hidden instead Try it Helpers
    .h1 - .h6 Makes an element look like a heading of the chosen class (h1-h6) Try it Typography
    .icon-bar Used in the navbar to create a hamburger menu (three horizontal bars) Try it Navbar
    .icon-next Unicode icon (arrow pointing right), used in carousels. This is often replaced with a glyphicon Try it Carousel
    .icon-prev Unicode icon (arrow pointing left), used in carousels. This is often replaced with a glyphicon Try it Carousel
    .img-circle Shapes an image to a circle (not supported in IE8 and earlier) Try it Images
    .img-responsive Makes an image responsive Try it Images
    .img-rounded Adds rounded corners to an image Try it Images
    .img-thumbnail Shapes an image to a thumbnail (borders) Try it Images
    .in Fades in tabs Try it Tabs
    .info Adds a light-blue background to the table row (<tr> or table cell (<td>). Indicates a neutral informative change or action Try it Tables
    .initialism Displays the text inside an <abbr> element in a slightly smaller font size Try it Typography
    .input-group Container to enhance an input by adding an icon, text or a button in front or behind it as a "help text" Try it Inputs
    .input-group-lg Large input group Try it Inputs
    .input-group-sm Small input group Try it Inputs
    .input-group-addon Together with the .input-group class, this class makes it possible to add an icon or help text next to the input field Try it Inputs
    .input-group-btn Together with the .input-group class, this class attaches a button next to an input. Often used as a search bar Try it Inputs
    .input-lg Large input field Try it Input Sizing
    .input-sm Small input field Try it Input Sizing
    .invisible Makes an element invisible (visibility:hidden). Note: Even though the element is invisible, it will take up space on the page Try it Helpers
    .item Class added to each carousel item. May be text or images Try it Carousel
    .jumbotron Creates a padded grey box with rounded corners that enlarges the font sizes of the text inside it. Creates a big box for calling extra attention to some special content or information Try it Jumbotron
    .label Adds a grey rounded box to an element. Provides additional information about something (e.g. "New") Try it Labels
    .label-danger Red label Try it Labels
    .label-info Light-blue label Try it Labels
    .label-success Green label Try it Labels
    .label-warning Yellow label Try it Labels
    .lead Increase the font size and line height of a paragraph Try it Typography
    .left Used to identify the left carousel control Try it Carousel
    .list-group Creates a bordered list group for <li> elements Try it List Group
    .list-group-item Added to each <li> element in the list group Try it List Group
    .list-group-item-heading Creates a list group heading (used on other elements besides <li>) Try it List Group
    .list-group-item-text Used for item text inside the list group (used on other elements besides <li>) Try it List Group
    .list-group-item-danger Red background color for a list item in a list group Try it List Group
    .list-group-item-info Light-blue background color for a list item in a list group Try it List Group
    .list-group-item-success Green background color for a list item in a list group Try it List Group
    .list-group-item-warning Yellow background color for a list item in a list group Try it List Group
    .list-inline Places all list items on a single line (horizontal menu) Try it Tabs
    .list-unstyled Removes all default list-style (bullets, left margin, etc.) styling from a <ul> or <ol> list Try it Typography
    .mark Highlights text: Highlighted text Try it Typography
    .media Aligns media objects (like images or videos - often used for comments in a blog post etc) Try it Media Objects
    .media-body Text that should appear next to a media object Try it Media Objects
    .media-heading Creates a heading inside the media object Try it Media Objects
    .media-list Nested media lists Try it Media Objects
    .media-object Indicates a media object (image or video) Try it Media Objects
    .modal Identifies the content as a modal and brings focus to it Try it Modals
    .modal-body Defines the style for the body of the modal. Add any HTML markup here (p, img, etc) Try it Modals
    .modal-content Styles the modal (border, background-color, etc). Inside this, add the modal's header, body and footer, if needed Try it Modals
    .modal-dialog Sets the proper width and margin of the modal Try it Modals
    .modal-footer The footer of the modal (often contains an action button and a close button) Try it Modals
    .modal-header The header of the modal (often contains a title and a close button) Try it Modals
    .modal-lg Large modal (wider than default) Try it Modals
    .modal-open Used on the <body> element to prevent page scrolling (overflow:hidden) Try it Modals
    .modal-sm Small modal (less width) Try it Modals
    .modal-title The title of the modal Try it Modals
    .nav nav-tabs Indicates a tabbed menu Try it Tabs
    .nav nav-pills Indicates a pill menu Try it Tabs
    .nav .navbar-nav Used on a <ul> container that contains the list items with links inside a navigation bar Try it Navbar
    .nav-justified Centers tabs/pills. Note that on screens smaller than 768px the items are stacked (content will remain centered) Try it Tabs
    .nav-stacked Vertically stack tabs or pills Try it Tabs
    .nav-tabs Creates a tabbed menu Try it Tabs
    .navbar Creates a navigation bar Try it Navbar
    .navbar-brand Added to a link or a header element inside the navbar to represent a logo or a header Try it Navbar
    .navbar-btn Vertically aligns a button inside a navbar Try it Navbar
    .navbar-collapse Collapses the navbar (hidden and replaced with a menu/hamburger icon on mobile phones and small tablets) Try it Navbar
    .navbar-default Creates a default navigation bar (light-grey background color) Try it Navbar
    .navbar-fixed-bottom Makes the navbar stay at the bottom of the screen (sticky/fixed) Try it Navbar
    .navbar-fixed-top Makes the navbar stay at the top of the screen (sticky/fixed) Try it Navbar
    .navbar-form Added to form elements inside the navbar to vertically center them (proper padding) Try it Navbar
    .navbar-header Added to a container element that contains the link/element that represent a logo or a header Try it Navbar
    .navbar-inverse Creates a black navigation bar (instead of light-grey) Try it Navbar
    .navbar-left Aligns nav links, forms, buttons, or text, in the navbar to the left Try it Navbar
    .navbar-link Styles an element to look like a link inside the navbar (anchors get proper padding and an underline on hover, while other elements like p or span gets a default hover effect - white color in an inversed navbar and a black color in a default navbar) Try it Navbar
    .navbar-nav Used on a <ul> container that contains the list items with links inside a navigation bar Try it Navbar
    .navbar-right Aligns nav links, forms, buttons, or text in the navbar to the right. Try it Navbar
    .navbar-static-top Removes left, top and right borders (rounded corners) from the navbar (default navbar has a gray border and a 4px border-radius by default) Try it Navbar
    .navbar-text Vertical align any elements inside the navbar that are not links (ensures proper padding) Try it Navbar
    .navbar-toggle Styles the button that should open the navbar on small screens. Often used together with three .icon-bar classes to indicate a toggleable menu icon (hamburger/bars) Try it Navbar
    .next Used in the carousel control to identity the next control Try it Carousel
    .next Used to align pager buttons to the right side of the page (next button) Try it Pager
    .page-header Adds a horizontal line under the heading (+ adds some extra space around the element) Try it Page Header
    .pager Creates previous/next buttons (used on <ul> elements) Try it Pager
    .pagination Creates a pagination (Useful when you have a web site with lots of pages. Used on <ul> elements) Try it Pagination
    .pagination-lg Large pagination (each pagination link gets a font-size of 18px. Default is 14px) Try it Pagination
    .pagination-sm Small pagination (each pagination link gets a font-size of 12px. Default is 14px) Try it Pagination
    .panel Creates a bordered box with some padding around its content Try it Panels
    .panel-body Container for content inside the panel Try it Panels
    .panel-collapse Collapsible panel (toggle between hiding and showing panel(s)) Try it Collapse
    .panel-danger Red panel. Indicates danger Try it Panels
    .panel-info Light-blue panel. Indicates information Try it Panels
    .panel-success Green panel. Indicates success Try it Panels
    .panel-warning Yellow panel. Indicates warning Try it Panels
    .panel-footer Creates a panel footer (light background color) Try it Panels
    .panel-group Used to group many panels together. This removes the bottom margin below each panel Try it Panels
    .panel-heading Creates a panel header (light background color) Try it Panels
    .panel-title Used inside a .panel-heading to adjust the styling of the text (removes margins and adds a font-size of 16px) Try it Panels
    .popover Popup-box that appears when the user clicks on an element Try it Popover
    .pre-scrollable Makes a <pre> element scrollable (max-height of 350px and provide a y-axis scrollbar) Try it Helpers
    .prev Used in carousels to indicate a "previous" link Try it Carousel
    .previous Used to align pager buttons to the left side of the page (previous button) Try it Pager
    .progress Container for progress bars Try it Progress Bars
    .progress-bar Creates a progress bar Try it Progress Bars
    .progress-bar-danger Red progress bar. Indicates danger Try it Progress Bars
    .progress-bar-info Light-blue progress bar. Indicates information Try it Progress Bars
    .progress-bar-striped Creates a striped progress bar Try it Progress Bars
    .progress-bar-success Green progress bar. Indicates success Try it Progress Bars
    .progress-bar-warning Yellow progress bar. Indicates warning Try it Progress Bars
    .pull-left Float an element to the left Try it Helpers
    .pull-right Float an element to the right Try it Helpers
    .right Used to identify the right carousel control Try it Carousel
    .row Container for responsive columns Try it Grid
    .row-no-gutters Removes the gutters from a row and its columns Try it Grid
    .show Shows an element (display:block) Try it Helpers
    .small Creates a lighter, secondary text in any heading Try it Typography
    .sr-only Hides an element on all devices except for screen readers Try it Helpers
    .sr-only-focusable Hides an element on all devices except for screen readers Try it Helpers
    .success Adds a green background color to a table row (<tr> or table cell (<td>). Indicates success or a positive action Try it Tables
    .tab-content Used together with .tab-pane to creates toggleable/dynamic tabs/pills Try it Tabs
    .tab-pane Used together with .tab-content to creates toggleable/dynamic tabs/pills Try it Tabs
    .table Adds basic styling to a table (padding, bottom borders, etc) Try it Tables
    .table-bordered Adds borders on all sides of the table and cells Try it Tables
    .table-condensed Makes a table more compact by cutting cell padding in half Try it Tables
    .table-hover Creates a hoverable table (adds a grey background color on table rows on hover) Try it Tables
    .table-responsive Makes a table responsive (adds a horizontal scrollbar when needed) Try it Tables
    .text-capitalize Indicates capitalized text Try it Typography
    .text-center Center-aligns text Try it Typography
    .text-danger Red text color. Indicates danger Try it Typography
    .text-hide Hides text (helps replace an element's text content with a background image) Try it Typography
    .text-info Light-blue text color. Indicates information Try it Typography
    .text-justify Indicates justified text Try it Typography
    .text-left Aligns the text to the left Try it Typography
    .text-lowercase Changes text to lowercase Try it Typography
    .text-muted Grey text color Try it Typography
    .text-nowrap Prevents the text from wrapping Try it Typography
    .text-primary Blue text color Try it Typography
    .text-right Aligns text to the right Try it Typography
    .text-success Green text color. Indicates success Try it Typography
    .text-uppercase Makes text uppercase Try it Typography
    .text-warning Yellow/orange text color. Indicates warning Try it Typography
    .thumbnail Adds a border around an element (often images or videos) to make it look like a thumbnail Try it Images
    .tooltip Popup-box that appears when the user moves the mouse pointer over an element Try it Tooltip
    .visible-* Deprecated as of v3.2.0. Used to show and/or hide content by device. Note: Use .hidden-* instead Try it Helpers
    .visible-print-block Displays the element (display:block) in print (pre)view Helpers
    .visible-print-inline Displays the element (display:inline) in print (pre)view Helpers
    .visible-print-inline-block Displays the element (display:inline-block) in print (pre)view Helpers
    .hidden-print Hides the element (display:none) in print (pre)view Helpers
    .warning Adds a yellow background color to the table row (<tr> or table cell (<td>). Indicates a warning Try it Tables
    .well Adds a rounded border around an element with a gray background color and some padding Try it Wells
    .well-lg Large well (more padding) Try it Wells
    .well-sm Small well (less padding) Try it Wells
    The table above shows all available Bootstrap 3 classes. Tip: To see the full list of all Bootstrap 4 classes, go to our All Bootstrap 4 CSS Classes Reference.

    Bootstrap CSS Typography Reference

    Bootstrap's Default Settings

    Bootstrap's global default font-size is 14px, with a line-height of 1.428. This is applied to the <body> and all paragraphs. In addition, all <p> elements have a bottom margin that equals half their computed line-height (10px by default).

    Typography

    The elements below are HTML elements that will be styled a little bit differently by Bootstrap than browser defaults. Look at the "Try it" examples to see the result/differences. The classes below is used to style the elements further.
    Element/ClassDescriptionExample
    <h1> - <h6> or .h1 - .h6h1 - h6 headingsTry it
    <small>Creates a lighter, secondary text in any heading

    Heading (secondary text)

    Try it
    .smallIndicates smaller text (set to 85% of the size of the parent): Smaller textTry it
    .leadMakes a text stand out: Stand out textTry it
    <mark> or .markHighlights text: Highlighted textTry it
    <del>Indicates deleted text: Deleted textTry it
    <s>Indicates no longer relevant text: No longer relevant textTry it
    <ins>Indicates inserted text: Inserted textTry it
    <u>Indicates underlined text: Underlined textTry it
    <strong>Indicates bold text: Bold textTry it
    <em>Indicates italic text: Italic textTry it
    .text-leftIndicates left-aligned textTry it
    .text-centerIndicates center-aligned textTry it
    .text-rightIndicates right-aligned textTry it
    .text-justifyIndicates justified textTry it
    .text-nowrapIndicates no wrap textTry it
    .text-lowercaseIndicates lowercased text: LOWERCASED TEXTTry it
    .text-uppercaseIndicates uppercased text: uppercased textTry it
    .text-capitalizeIndicates capitalized text: capitalized textTry it
    <abbr>The <abbr> element indicates an abbreviation or acronym. Abbreviations with a title attribute have a dotted bottom border and a help cursor on hover, providing additional context on hover.Try it
    .initialismDisplays the text inside the <abbr> element in a slightly smaller font sizeTry it
    <address>Presents contact informationTry it
    <blockquote>Indicates blocks of content from another sourceTry it
    .blockquote-reverseIndicates a blockquote with right-aligned contentTry it
    <ul>Indicates an unordered listTry it
    <ol>Indicates an ordered listTry it
    .list-unstyledRemoves the default list-style and left margin on list items (works on both <ul> and <ol>). This class only applies to immediate children list items (to remove the default list-style from any nested lists, apply this class to any nested lists as well)Try it
    .list-inlinePlaces all list items on a single lineTry it
    <dl>Indicates a description listTry it
    .dl-horizontalLines up the terms and descriptions in the <dl> element side-by-side. Starts off like default <dl>s, but when the browser window expands, it will line up side-by-sideTry it

    Code

    Element/ClassDescriptionExample
    <var>Indicates variables: x = ab + yTry it
    <kbd>Indicates input that is typically entered via the keyboard: CTRL + PTry it
    <pre>Indicates multiple lines of codeTry it
    <pre class="pre-scrollable">Indicates multiple lines of code with scrollbarTry it
    <samp>Indicates sample output from a computer program: Sample outputTry it
    <code>Indicates inline snippets of code: span, div Try it

    Bootstrap CSS Buttons Reference

    Button Colors

    Button Sizes

    Active/Disabled Buttons

    Block-level Button

    Button Groups

    Button Classes

    The classes below can be used to style any <a>, <button>, or <input> element:
    ClassDescriptionExample
    .btnAdds basic styling to any buttonTry it
    .btn-defaultIndicates a default/standard buttonTry it
    .btn-primaryProvides extra visual weight and identifies the primary action in a set of buttonsTry it
    .btn-successIndicates a successful or positive actionTry it
    .btn-infoContextual button for informational alert messagesTry it
    .btn-warningIndicates caution should be taken with this actionTry it
    .btn-dangerIndicates a dangerous or potentially negative actionTry it
    .btn-linkMakes a button look like a link (will still have button behavior)Try it
    .btn-lgMakes a large buttonTry it
    .btn-smMakes a small buttonTry it
    .btn-xsMakes an extra small buttonTry it
    .btn-blockMakes a block-level button (spans the full width of the parent element)Try it
    .activeMakes the button appear pressedTry it
    .disabledMakes the button disabledTry it
    .navbar-btn Vertically aligns a button inside a navbar Try it

    Button Group Classes

    The classes below can be used to style any <a>, <button>, or <input> element:
    ClassDescriptionExample
    .btn-group Groups buttons together on a single line Try it
    .btn-group-justified Makes a group of buttons span the entire width of the screen Try it
    .btn-group-lg Large button group (makes all buttons in a button group larger - increased font-size and padding) Try it
    .btn-group-sm Small button group (makes all buttons in a button group smaller) Try it
    .btn-group-xs Extra small button group (makes all buttons in a button group extra small) Try it
    .btn-group-vertical Makes a button group appear vertically stacked Try it

    Bootstrap CSS Forms Reference

    Bootstrap's Default Settings

    Individual form controls automatically receive some global styling with Bootstrap. All textual <input>, <textarea>, and <select> elements with class="form-control" are set to width: 100%; by default. Standard rules for all three form layouts:
  • Wrap labels and form controls in <div class="form-group"> (needed for optimum spacing)
  • Add class .form-control to all textual <input>, <textarea>, and <select> elements
  • The following example creates a simple Bootstrap form with two input fields, one checkbox, and a submit button:

    Bootstrap Form Example

    <form> <div class="form-group"> <label for="email">Email address:</label> <input type="email" class="form-control" id="email"> </div> <div class="form-group"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd"> </div> <div class="checkbox"> <label><input type="checkbox"> Remember me</label> </div> <button type="submit" class="btn btn-default">Submit</button> </form> Try it Yourself »

    Form Classes

    ClassDescriptionExample
    .form-inlineMakes a <form> left-aligned with inline-block controls (This only applies to forms within viewports that are at least 768px wide)Try it
    .form-horizontalAligns labels and groups of form controls in a horizontal layoutTry it
    .form-control Used on input, textarea, and select elements to span the entire width of the page and make them responsive Try it
    .form-control-feedback Form validation class Try it
    .form-control-static Adds plain text next to a form label within a horizontal form Try it
    .form-group Container for form input and label Try it

    Input Classes

    ClassDescriptionExample
    .input-group Container to enhance an input by adding an icon, text or a button in front or behind it as a "help text" Try it
    .input-group-lg Large input group Try it
    .input-group-sm Small input group Try it
    .input-group-addon Together with the .input-group class, this class makes it possible to add an icon or help text next to the input field Try it
    .input-group-btn Together with the .input-group class, this class attaches a button next to an input. Often used as a search bar Try it
    .input-lg Large input field Try it
    .input-sm Small input field Try it

    Bootstrap CSS Helper Classes Reference

    Text

    Add meaning through text-colors with the classes below. Links will darken on hover:
    ClassDescriptionExample
    .text-mutedText styled with class "text-muted"Try it
    .text-primaryText styled with class "text-primary"Try it
    .text-successText styled with class "text-success"Try it
    .text-infoText styled with class "text-info"Try it
    .text-warningText styled with class "text-warning"Try it
    .text-dangerText styled with class "text-danger"Try it

    Background

    Add meaning through background-colors with the classes below. Links will darken on hover just like text classes:
    ClassDescriptionExample
    .bg-primary Table cell is styled with class "bg-primary"Try it
    .bg-success Table cell is styled with class "bg-success"Try it
    .bg-info Table cell is styled with class "bg-info"Try it
    .bg-warning Table cell is styled with class "bg-warning"Try it
    .bg-danger Table cell is styled with class "bg-danger"Try it

    Other

    ClassDescriptionExample
    .pull-leftFloats an element to the leftTry it
    .pull-rightFloats an element to the rightTry it
    .center-blockSets an element to display:block with margin-right:auto and margin-left:autoTry it
    .clearfixClears floatsTry it
    .showForces an element to be shown (display:block)Try it
    .hiddenForces an element to be hidden (display:none)Try it
    .invisibleForces an element to be invisible (visibility:hidden). Will take up space on page even though it is invisibleTry it
    .sr-onlyHides an element to all devices except screen readersTry it
    .sr-only-focusableCombine with .sr-only to show the element again when it is focused (e.g. by a keyboard-only user)Try it
    .text-hideHelps replace an element's text content with a background imageTry it
    .closeIndicates a close iconTry it
    .caretIndicates dropdown functionality (will reverse automatically in dropup menus)Try it

    Responsive Utilities

    These classes are used to show and/or hide content by device via media queries. Use one or a combination of the available classes for toggling content across viewport breakpoints:
    Classes 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

    Hidden

    Hide elements depending on screen size:

    Example

    <h2>Example</h2> <p>Resize this page to see how the text below changes:</p> <h1 class="hidden-xs bg-danger">This text is hidden on an EXTRA SMALL screen.</h1> <h1 class="hidden-sm bg-info">This text is hidden on a SMALL screen.</h1> <h1 class="hidden-md bg-warning">This is text hidden on a MEDIUM screen.</h1> <h1 class="hidden-lg bg-success">This is text hidden on a LARGE screen.</h1> Result:

    Example

    Resize this page to see how the text below changes:

    This text is hidden on an EXTRA SMALL screen.

    This text is hidden on a SMALL screen.

    This is text hidden on a MEDIUM screen.

    This is text hidden on a LARGE screen.

    Try it Yourself » As of v3.2.0, the .visible-*-* classes for come in three variations, one for each CSS display property value:
    Group of classes CSS display
    visible-*-block display: block;
    .visible-*-inline display: inline;
    .visible-*-inline-block display: inline-block;
    E.g. for small (sm) screens, the available .visible-*-* classes are: .visible-sm-block, .visible-sm-inline, and .visible-sm-inline-block. The classes .visible-xs, .visible-sm, .visible-md, and .visible-lg are deprecated as of v3.2.0.

    Example

    <h2>Example</h2> <p>Resize this page to see how the text below changes:</p> <h1 class="visible-xs">This text is shown only on an EXTRA SMALL screen.</h1> <h1 class="visible-sm">This text is shown only on a SMALL screen.</h1> <h1 class="visible-md">This text is shown only on a MEDIUM screen.</h1> <h1 class="visible-lg">This text is shown only on a LARGE screen.</h1> Result:

    Example

    Resize this page to see how the text below changes:

    This text is shown only on an EXTRA SMALL screen.

    This text is shown only on a SMALL screen.

    This text is shown only on a MEDIUM screen.

    This text is shown only on a LARGE screen.

    Try it Yourself »

    Bootstrap CSS Images Reference

    Bootstrap Images

    Rounded Corners: Cinque Terre Circle: Cinque Terre Thumbnail: Cinque Terre

    <img> Classes

    The classes below can be used to style any image:
    ClassDescriptionExample
    .img-roundedAdds rounded corners to an image (not available in IE8)Try it
    .img-circleShapes the image to a circle (not available in IE8)Try it
    .img-thumbnailShapes the image to a thumbnailTry it
    .img-responsiveMakes an image responsive (will scale nicely to the parent element)Try it

    Responsive Images

    Create responsive images by adding an .img-responsive class to the <img> tag. The image will then scale nicely to the parent element. The .img-responsive class applies max-width: 100%, height: auto, and display:block to the image:

    Example

    <img src="cinqueterre.jpg" class="img-responsive" alt="Cinque Terre"> Try it Yourself »

    Bootstrap CSS Tables Reference

    <table> Classes

    Use the classes below to style any table:
    ClassDescriptionExample
    .tableAdds basic styling (light padding and only horizontal dividers) to any <table>Try it
    .table-stripedAdds zebra-striping to any table row within <tbody> (not available in IE8)Try it
    .table-borderedAdds border on all sides of the table and cellsTry it
    .table-hoverEnables a hover state on table rows within a <tbody>Try it
    .table-condensedMakes table more compact by cutting cell padding in halfTry it
    Combining all the table classesTry it

    <tr>, <th> and <td> Classes

    Use the classes below to color table rows or cells:
    ClassDescriptionExample
    .activeApplies the hover color (light-grey) to a particular row or cellTry it
    .successIndicates a successful or positive actionTry it
    .infoIndicates a neutral informative change or actionTry it
    .warningIndicates a warning that might need attentionTry it
    .dangerIndicates a dangerous or potentially negative actionTry it

    Responsive Tables

    The .table-responsive class creates a responsive table. The table will then scroll horizontally on small devices (under 768px). When viewing on anything larger than 768px wide, there is no difference:

    Example

    <div class="table-responsive"> <table> ... </table> </div> Try it Yourself »

    Bootstrap Dropdown Components

    Dropdowns

    For a tutorial about Dropdowns, read our Bootstrap Dropdowns Tutorial.
    ClassDescriptionExample
    .dropdownIndicates a dropdown menuTry it
    .dropdown-menuBuilds the dropdown menuTry it
    .dropdown-menu-rightRight-aligns a dropdown menuTry it
    .dropdown-headerAdds a header inside the dropdown menuTry it
    .dropupIndicates a dropup menuTry it
    .disabledDisables an item in the dropdown menuTry it
    .dividerSeparates items inside the dropdown menu with a horizontal lineTry it

    Collapsibles

    For a tutorial about collapsibles, read our Bootstrap Collapse Tutorial.
    ClassDescriptionExample
    .collapseIndicates collapsible content - which can be hidden or shown on demandTry it
    .collapse .inShow the collapsible content by defaultTry it
    .panel-collapseCollapsible panel (toggle between hiding and showing panel(s))Try it
    Collapsible list groupTry it
    AccordionTry it

    Bootstrap Navigation Components

    Tabs and Pills

    ClassDescriptionExample
    .nav nav-tabsCreates navigation tabsTry it
    .nav nav-pillsCreates navigation pillsTry it
    .nav nav-pills nav-stackedCreates vertical navigation pillsTry it
    .nav-justifiedMakes navigation tabs/pills equal widths of their parent, at screens wider than 768px. On smaller screens, the nav tabs/pills are stackedTry it
    .disabledIndicates a disabled (unclickable) tab/pillTry it
    Navigation tabs with dropdown menuTry it
    Navigation pills with dropdown menuTry it
    .tab-contentTogether with .tab-pane and data-toggle="tab" (data-toggle="pill" for pills), it makes the tab/pill toggleableTry it
    .tab-paneTogether with .tab-content and data-toggle="tab" (data-toggle="pill" for pills), it makes the tab/pill toggleableTry it

    Navbars

    ClassDescriptionExample
    .navbar Creates a navigation bar Try it
    .navbar-brand Added to a link or a header element inside the navbar to represent a logo or a header Try it
    .navbar-btn Vertically aligns a button inside a navbar Try it
    .navbar-collapse Collapses the navbar (hidden and replaced with a menu/hamburger icon on mobile phones and small tablets) Try it
    .navbar-default Creates a default navigation bar (light-grey background color) Try it
    .navbar-fixed-bottom Makes the navbar stay at the bottom of the screen (sticky/fixed) Try it
    .navbar-fixed-top Makes the navbar stay at the top of the screen (sticky/fixed) Try it
    .navbar-form Added to form elements inside the navbar to vertically center them (proper padding) Try it
    .navbar-header Added to a container element that contains the link/element that represent a logo or a header Try it
    .navbar-inverse Creates a black navigation bar (instead of light-grey) Try it
    .navbar-left Aligns nav links, forms, buttons, or text, in the navbar to the left Try it
    .navbar-link Styles an element to look like a link inside the navbar (anchors get proper padding and an underline on hover, while other elements like p or span gets a default hover effect - white color in an inversed navbar and a black color in a default navbar) Try it
    .navbar-nav Used on a <ul> container that contains the list items with links inside a navigation bar Try it
    .navbar-right Aligns nav links, forms, buttons, or text in the navbar to the right. Try it
    .navbar-static-top Removes left, top and right borders (rounded corners) from the navbar (default navbar has a gray border and a 4px border-radius by default)
    .navbar-text Vertical align any elements inside the navbar that are not links (ensures proper padding) Try it
    .navbar-toggle Styles the button that should open the navbar on small screens. Often used together with three .icon-bar classes to indicate a toggleable menu icon (hamburger/bars) Try it

    Breadcrumbs and Pagination

    ClassDescriptionExample
    .breadcrumbMakes a breadcrumbTry it
    .pagerProvides simple pagination links (Previous/Next)Try it
    .previousAligns the .pager previous button to the leftTry it
    .nextAligns the .pager next button to the rightTry it
    .disabledIndicates an unclickable linkTry it
    .paginationProvides pagination linksTry it
    .pagination-lgUsed together with the .pagination class to provide larger pagination linksTry it
    .pagination-smUsed together with the .pagination class to provide smaller pagination linksTry it
    .disabledIndicates an unclickable link Try it
    .activeIndicates the current page Try it

    Labels and Badges

    ClassDescriptionExample
    .label label-defaultIndicates a default grey labelTry it
    .label label-primaryIndicates a blue label of type "primary"Try it
    .label label-successIndicates a green label of type "success"Try it
    .label label-infoIndicates a light blue label of type "info"Try it
    .label label-warningIndicates a yellow label of type "warning"Try it
    .label label-dangerIndicates a red label of type "danger"Try it
    .badgeIndicates new or unread itemsTry it
    .jumbotronIndicates a big box for calling extra attention to featured content or informationTry it
    .jumbotron (extra)To let the .jumbotron box span the full width, and without rounded corners, place it outside the .container classTry it

    Bootstrap Glyphicon Components

    Glyphicons

    Bootstrap includes 260 glyphs from the Glyphicon Halflings set. Glyphicons Halflings are normally not available for free, but their creator has made them available for Bootstrap free of cost. As a thank you, you should include a link back to Glyphicons whenever possible. Use glyphicons in text, buttons, toolbars, navigation, or forms:

    Bootstrap Glyph Example

    <p>Envelope icon: <span class="glyphicon glyphicon-envelope"></span></p> <p>Search icon: <span class="glyphicon glyphicon-search"></span></p> <p>Print icon: <span class="glyphicon glyphicon-print"></span></p> Try it Yourself »

    Available Glyphs

    GlyphDescriptionExample
    glyphicon glyphicon-asteriskTry it
    glyphicon glyphicon-plusTry it
    glyphicon glyphicon-minusTry it
    glyphicon glyphicon-euroTry it
    glyphicon glyphicon-cloudTry it
    glyphicon glyphicon-envelopeTry it
    glyphicon glyphicon-pencilTry it
    glyphicon glyphicon-glassTry it
    glyphicon glyphicon-musicTry it
    glyphicon glyphicon-searchTry it
    glyphicon glyphicon-heartTry it
    glyphicon glyphicon-starTry it
    glyphicon glyphicon-star-emptyTry it
    glyphicon glyphicon-userTry it
    glyphicon glyphicon-filmTry it
    glyphicon glyphicon-th-largeTry it
    glyphicon glyphicon-thTry it
    glyphicon glyphicon-th-listTry it
    glyphicon glyphicon-okTry it
    glyphicon glyphicon-removeTry it
    glyphicon glyphicon-zoom-inTry it
    glyphicon glyphicon-zoom-outTry it
    glyphicon glyphicon-offTry it
    glyphicon glyphicon-signalTry it
    glyphicon glyphicon-cogTry it
    glyphicon glyphicon-trashTry it
    glyphicon glyphicon-homeTry it
    glyphicon glyphicon-fileTry it
    glyphicon glyphicon-timeTry it
    glyphicon glyphicon-roadTry it
    glyphicon glyphicon-download-altTry it
    glyphicon glyphicon-downloadTry it
    glyphicon glyphicon-uploadTry it
    glyphicon glyphicon-inboxTry it
    glyphicon glyphicon-play-circleTry it
    glyphicon glyphicon-repeatTry it
    glyphicon glyphicon-refreshTry it
    glyphicon glyphicon-list-altTry it
    glyphicon glyphicon-lockTry it
    glyphicon glyphicon-flagTry it
    glyphicon glyphicon-headphonesTry it
    glyphicon glyphicon-volume-offTry it
    glyphicon glyphicon-volume-downTry it
    glyphicon glyphicon-volume-upTry it
    glyphicon glyphicon-qrcodeTry it
    glyphicon glyphicon-barcodeTry it
    glyphicon glyphicon-tagTry it
    glyphicon glyphicon-tagsTry it
    glyphicon glyphicon-bookTry it
    glyphicon glyphicon-bookmarkTry it
    glyphicon glyphicon-printTry it
    glyphicon glyphicon-cameraTry it
    glyphicon glyphicon-fontTry it
    glyphicon glyphicon-boldTry it
    glyphicon glyphicon-italicTry it
    glyphicon glyphicon-text-heightTry it
    glyphicon glyphicon-text-widthTry it
    glyphicon glyphicon-align-leftTry it
    glyphicon glyphicon-align-centerTry it
    glyphicon glyphicon-align-rightTry it
    glyphicon glyphicon-align-justifyTry it
    glyphicon glyphicon-listTry it
    glyphicon glyphicon-indent-leftTry it
    glyphicon glyphicon-indent-rightTry it
    glyphicon glyphicon-facetime-videoTry it
    glyphicon glyphicon-pictureTry it
    glyphicon glyphicon-map-markerTry it
    glyphicon glyphicon-adjustTry it
    glyphicon glyphicon-tintTry it
    glyphicon glyphicon-editTry it
    glyphicon glyphicon-shareTry it
    glyphicon glyphicon-checkTry it
    glyphicon glyphicon-moveTry it
    glyphicon glyphicon-step-backwardTry it
    glyphicon glyphicon-fast-backwardTry it
    glyphicon glyphicon-backwardTry it
    glyphicon glyphicon-playTry it
    glyphicon glyphicon-pauseTry it
    glyphicon glyphicon-stopTry it
    glyphicon glyphicon-forwardTry it
    glyphicon glyphicon-fast-forwardTry it
    glyphicon glyphicon-step-forwardTry it
    glyphicon glyphicon-ejectTry it
    glyphicon glyphicon-chevron-leftTry it
    glyphicon glyphicon-chevron-rightTry it
    glyphicon glyphicon-plus-signTry it
    glyphicon glyphicon-minus-signTry it
    glyphicon glyphicon-remove-signTry it
    glyphicon glyphicon-ok-signTry it
    glyphicon glyphicon-question-signTry it
    glyphicon glyphicon-info-signTry it
    glyphicon glyphicon-screenshotTry it
    glyphicon glyphicon-remove-circleTry it
    glyphicon glyphicon-ok-circleTry it
    glyphicon glyphicon-ban-circleTry it
    glyphicon glyphicon-arrow-leftTry it
    glyphicon glyphicon-arrow-rightTry it
    glyphicon glyphicon-arrow-upTry it
    glyphicon glyphicon-arrow-downTry it
    glyphicon glyphicon-share-altTry it
    glyphicon glyphicon-resize-fullTry it
    glyphicon glyphicon-resize-smallTry it
    glyphicon glyphicon-exclamation-signTry it
    glyphicon glyphicon-giftTry it
    glyphicon glyphicon-leafTry it
    glyphicon glyphicon-fireTry it
    glyphicon glyphicon-eye-openTry it
    glyphicon glyphicon-eye-closeTry it
    glyphicon glyphicon-warning-signTry it
    glyphicon glyphicon-planeTry it
    glyphicon glyphicon-calendarTry it
    glyphicon glyphicon-randomTry it
    glyphicon glyphicon-commentTry it
    glyphicon glyphicon-magnetTry it
    glyphicon glyphicon-chevron-upTry it
    glyphicon glyphicon-chevron-downTry it
    glyphicon glyphicon-retweetTry it
    glyphicon glyphicon-shopping-cartTry it
    glyphicon glyphicon-folder-closeTry it
    glyphicon glyphicon-folder-openTry it
    glyphicon glyphicon-resize-verticalTry it
    glyphicon glyphicon-resize-horizontalTry it
    glyphicon glyphicon-hddTry it
    glyphicon glyphicon-bullhornTry it
    glyphicon glyphicon-bellTry it
    glyphicon glyphicon-certificateTry it
    glyphicon glyphicon-thumbs-upTry it
    glyphicon glyphicon-thumbs-downTry it
    glyphicon glyphicon-hand-rightTry it
    glyphicon glyphicon-hand-leftTry it
    glyphicon glyphicon-hand-upTry it
    glyphicon glyphicon-hand-downTry it
    glyphicon glyphicon-circle-arrow-rightTry it
    glyphicon glyphicon-circle-arrow-leftTry it
    glyphicon glyphicon-circle-arrow-upTry it
    glyphicon glyphicon-circle-arrow-downTry it
    glyphicon glyphicon-globeTry it
    glyphicon glyphicon-wrenchTry it
    glyphicon glyphicon-tasksTry it
    glyphicon glyphicon-filterTry it
    glyphicon glyphicon-briefcaseTry it
    glyphicon glyphicon-fullscreenTry it
    glyphicon glyphicon-dashboardTry it
    glyphicon glyphicon-paperclipTry it
    glyphicon glyphicon-heart-emptyTry it
    glyphicon glyphicon-linkTry it
    glyphicon glyphicon-phoneTry it
    glyphicon glyphicon-pushpinTry it
    glyphicon glyphicon-usdTry it
    glyphicon glyphicon-gbpTry it
    glyphicon glyphicon-sortTry it
    glyphicon glyphicon-sort-by-alphabetTry it
    glyphicon glyphicon-sort-by-alphabet-altTry it
    glyphicon glyphicon-sort-by-orderTry it
    glyphicon glyphicon-sort-by-order-altTry it
    glyphicon glyphicon-sort-by-attributesTry it
    glyphicon glyphicon-sort-by-attributes-altTry it
    glyphicon glyphicon-uncheckedTry it
    glyphicon glyphicon-expandTry it
    glyphicon glyphicon-collapse-downTry it
    glyphicon glyphicon-collapse-upTry it
    glyphicon glyphicon-log-inTry it
    glyphicon glyphicon-flashTry it
    glyphicon glyphicon-log-outTry it
    glyphicon glyphicon-new-windowTry it
    glyphicon glyphicon-recordTry it
    glyphicon glyphicon-saveTry it
    glyphicon glyphicon-openTry it
    glyphicon glyphicon-savedTry it
    glyphicon glyphicon-importTry it
    glyphicon glyphicon-exportTry it
    glyphicon glyphicon-sendTry it
    glyphicon glyphicon-floppy-diskTry it
    glyphicon glyphicon-floppy-savedTry it
    glyphicon glyphicon-floppy-removeTry it
    glyphicon glyphicon-floppy-saveTry it
    glyphicon glyphicon-floppy-openTry it
    glyphicon glyphicon-credit-cardTry it
    glyphicon glyphicon-transferTry it
    glyphicon glyphicon-cutleryTry it
    glyphicon glyphicon-headerTry it
    glyphicon glyphicon-compressedTry it
    glyphicon glyphicon-earphoneTry it
    glyphicon glyphicon-phone-altTry it
    glyphicon glyphicon-towerTry it
    glyphicon glyphicon-statsTry it
    glyphicon glyphicon-sd-videoTry it
    glyphicon glyphicon-hd-videoTry it
    glyphicon glyphicon-subtitlesTry it
    glyphicon glyphicon-sound-stereoTry it
    glyphicon glyphicon-sound-dolbyTry it
    glyphicon glyphicon-sound-5-1Try it
    glyphicon glyphicon-sound-6-1Try it
    glyphicon glyphicon-sound-7-1Try it
    glyphicon glyphicon-copyright-markTry it
    glyphicon glyphicon-registration-markTry it
    glyphicon glyphicon-cloud-downloadTry it
    glyphicon glyphicon-cloud-uploadTry it
    glyphicon glyphicon-tree-coniferTry it
    glyphicon glyphicon-tree-deciduousTry it
    glyphicon glyphicon-cdTry it
    glyphicon glyphicon-save-fileTry it
    glyphicon glyphicon-open-fileTry it
    glyphicon glyphicon-level-upTry it
    glyphicon glyphicon-copyTry it
    glyphicon glyphicon-pasteTry it
    glyphicon glyphicon-alertTry it
    glyphicon glyphicon-equalizerTry it
    glyphicon glyphicon-kingTry it
    glyphicon glyphicon-queenTry it
    glyphicon glyphicon-pawnTry it
    glyphicon glyphicon-bishopTry it
    glyphicon glyphicon-knightTry it
    glyphicon glyphicon-baby-formulaTry it
    glyphicon glyphicon-tentTry it
    glyphicon glyphicon-blackboardTry it
    glyphicon glyphicon-bedTry it
    glyphicon glyphicon-appleTry it
    glyphicon glyphicon-eraseTry it
    glyphicon glyphicon-hourglassTry it
    glyphicon glyphicon-lampTry it
    glyphicon glyphicon-duplicateTry it
    glyphicon glyphicon-piggy-bankTry it
    glyphicon glyphicon-scissorsTry it
    glyphicon glyphicon-bitcoinTry it
    glyphicon glyphicon-yenTry it
    glyphicon glyphicon-rubleTry it
    glyphicon glyphicon-scaleTry it
    glyphicon glyphicon-ice-lollyTry it
    glyphicon glyphicon-ice-lolly-tastedTry it
    glyphicon glyphicon-educationTry it
    glyphicon glyphicon-option-horizontalTry it
    glyphicon glyphicon-option-verticalTry it
    glyphicon glyphicon-menu-hamburgerTry it
    glyphicon glyphicon-modal-windowTry it
    glyphicon glyphicon-oilTry it
    glyphicon glyphicon-grainTry it
    glyphicon glyphicon-sunglassesTry it
    glyphicon glyphicon-text-sizeTry it
    glyphicon glyphicon-text-colorTry it
    glyphicon glyphicon-text-backgroundTry it
    glyphicon glyphicon-object-align-topTry it
    glyphicon glyphicon-object-align-bottomTry it
    glyphicon glyphicon-object-align-horizontalTry it
    glyphicon glyphicon-object-align-leftTry it
    glyphicon glyphicon-object-align-verticalTry it
    glyphicon glyphicon-object-align-rightTry it
    glyphicon glyphicon-triangle-rightTry it
    glyphicon glyphicon-triangle-leftTry it
    glyphicon glyphicon-triangle-bottomTry it
    glyphicon glyphicon-triangle-topTry it
    glyphicon glyphicon-superscriptTry it
    glyphicon glyphicon-subscriptTry it
    glyphicon glyphicon-menu-leftTry it
    glyphicon glyphicon-menu-rightTry it
    glyphicon glyphicon-menu-downTry it
    glyphicon glyphicon-menu-upTry it

    Bootstrap JS Affix

    JS Affix (affix.js)

    The Affix plugin allows an element to become affixed (locked) to an area on the page. This is often used with navigation menus or social icon buttons, to make them "stick" at a specific area while scrolling up and down the page. The plugin toggles this behavior on and off (changes the value of CSS position from static to fixed), depending on scroll position. The affix plugin toggles between three classes: .affix, .affix-top, and .affix-bottom. Each class represents a particular state. You must add CSS properties to handle the actual positions, with the exception of position:fixed on the .affix class. For more information, read our Bootstrap Affix Tutorial. Tip: The Affix plugin is often used together with the Scrollspy plugin.

    Via data-* Attributes

    Add data-spy="affix" to the element you want to spy on, and the data-offset-top|bottom="number" attribute to calculate the position of the scroll.

    Example

    <ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="205"> Try it Yourself »

    Via JavaScript

    Enable manually with:

    Example

    $('.nav').affix({offset: {top: 150} }); Try it Yourself »

    Affix Options

    Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-offset=".
    NameTypeDefaultDescription
    offsetnumber | object | function10 Specifies the number of pixels to offset from screen when calculating position of scroll. When using a single number, the offset is added to both top and bottom directions. If you only want to control the top or the bottom, use an object, like offset: {top:25} For multiple offsets, use offset: {top:25, bottom:50} Tip: Use a function to dynamically provide an offset (can be useful for responsive designs)
    targetselector | node | elementthe window object Specifies the target element of the affix

    Affix Events

    The following table lists all available affix events.
    EventDescriptionTry it
    affix.bs.affixOccurs before fixed positioning is added to the element (e.g, when the .affix-top class is about to be replaced with the .affix class)Try it
    affixed.bs.affixOccurs after fixed positioning is added to the element (e.g., after the .affix-top class is replaced with the .affix class)Try it
    affix-top.bs.affixOccurs before the top element returns to its original (non-fixed) position (e.g., the .affix class is about to be replaced with .affix-top)Try it
    affixed-top.bs.affixOccurs after the top element returns to its original (non-fixed) position (e.g., the .affix class has been replaced with .affix-top)Try it
    affix-bottom.bs.affixOccurs before the bottom element returns to its original (non-fixed) position (e.g., the .affix class is about to be replaced with .affix-bottom)Try it
    affixed-bottom.bs.affixOccurs after the bottom element returns to its original (non-fixed) position (e.g., the .affix class has been replaced with .affix-bottom)Try it

    More Examples

    Affixed navbar

    Create a horizontal affixed navigation menu:

    Example

    <nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="197"> Try it Yourself »

    Using jQuery to automatically affix a navbar

    Use jQuery's outerHeight() method to affix the navbar after the user has scrolled passed a specified element (<header>):

    Example

    $(".navbar").affix({offset: {top: $("header").outerHeight(true)} }); Try it Yourself »

    Scrollspy & Affix

    Using the Affix plugin together with the Scrollspy plugin:

    Horizontal Menu (Navbar)

    <body data-spy="scroll" data-target=".navbar" data-offset="50"> <nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="197"> ... </nav> </body> Try it Yourself »

    Vertical Menu (Sidenav)

    <body data-spy="scroll" data-target="#myScrollspy" data-offset="15"> <nav class="col-sm-3" id="myScrollspy"> <ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="205"> ... </nav> </body> Try it Yourself »

    Animated navbar on affix

    Use CSS to manipulate the different .affix classes:

    Example - Change background color and padding of navbar on scroll

    .affix { top: 0; width: 100%; -webkit-transition: all .5s ease-in-out; transition: all .5s ease-in-out; background-color: #F44336; border-color: #F44336; } .affix a { color: #fff !important; padding: 15px !important; -webkit-transition: all .5s ease-in-out; transition: all .5s ease-in-out; } .affix-top a { padding: 25px !important; } Try it Yourself »

    Example - Slide in the navbar

    .affix { top: 0; width: 100%; -webkit-transition: all .5s ease-in-out; transition: all .5s ease-in-out; } .affix-top { position: static; top: -35px; } Try it Yourself »

    Bootstrap JS Alert

    JS Alert (alert.js)

    The alert plugin include options and methods to close alert messages. For a tutorial about Alerts, read our Bootstrap Alerts Tutorial.

    The Alert Plugin Classes

    ClassDescriptionExample
    .alertCreates an alert message boxTry it
    .alert-dangerRed alert. Indicates a dangerous or potentially negative actionTry it
    .alert-dismissibleIndicates a closable alert box. Together with the .close class, this class is used to close the alert (adds extra padding)Try it
    .alert-infoLight-blue alert.Indicates a neutral informative change or actionTry it
    .alert-linkUsed on links inside alerts to provide matching colored linksTry it
    .alert-successGreen alert. Indicates a successful or positive actionTry it
    .alert-warningYellow alert. Indicates caution should be taken with this actionTry it
    .closeStyles the close button for the alert message (floats right with a specified font-size, color, etc.)Try it

    Close Alerts Via data-* Attributes

    Add data-dismiss="alert" to a link or a button element to close the alert message.

    Example

    <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> Try it Yourself »

    Close Alerts Via JavaScript

    Close manually with:

    Example

    $('.close').alert(); Try it Yourself »

    Alert Options

    None

    Alert Methods

    The following table lists all available alert methods.
    MethodDescriptionTry it
    .alert("close")Closes the alert messageTry it

    Alert Events

    The following table lists all available alert events.
    EventDescriptionTry it
    close.bs.alertOccurs when the alert message is about to be closedTry it
    closed.bs.alertOccurs when the alert message has been closedTry it

    Bootstrap JS Button

    JS Button (button.js)

    Use this plugin if you want to have more control over your buttons. For a tutorial about Buttons, read our Bootstrap Buttons Tutorial.

    The Button Plugin Classes

    The classes below can be used to style any <a>, <button>, or <input> element:
    ClassDescriptionExample
    .btnAdds basic styling to any buttonTry it
    .btn-defaultIndicates a default/standard buttonTry it
    .btn-primaryProvides extra visual weight and identifies the primary action in a set of buttonsTry it
    .btn-successIndicates a successful or positive actionTry it
    .btn-infoContextual button for informational alert messagesTry it
    .btn-warningIndicates caution should be taken with this actionTry it
    .btn-dangerIndicates a dangerous or potentially negative actionTry it
    .btn-linkMakes a button look like a link (will still have button behavior)Try it
    .btn-lgMakes a large buttonTry it
    .btn-smMakes a small buttonTry it
    .btn-xsMakes an extra small buttonTry it
    .btn-blockMakes a block-level button (spans the full width of the parent element)Try it
    .activeMakes the button appear pressedTry it
    .disabledMakes the button disabledTry it

    Via JavaScript

    Enable manually with: $('.btn').button();

    Button Options

    None

    Button Methods

    The following table lists all available button methods. Note: For this plugin, methods can also be passed via data attributes; append the method name to data-, as in data-toggle or data-loading.
    MethodDescriptionTry it
    .button("toggle")Makes the button look pressedTry it
    .button("loading")Disables the button and changes the button text to "loading..."Try it
    .button("reset")Changes the button text to original text (if changed)Try it
    .button("string")Specifies a new button textTry it

    More Examples

    Using CSS to Customize Buttons

    How to remove the rounded borders:

    Example

    .btn-default { border-radius: 0; } Try it Yourself » How to add a specific color:

    Example

    .btn-default { background: #000; color: #fff; } .btn-default:hover { background: #fff; color: #000; } Try it Yourself » How to add shadows:

    Example

    .btn-default { box-shadow: 1px 2px 5px #000000; } Try it Yourself »

    Bootstrap JS Carousel

    JS Carousel (carousel.js)

    The Carousel plugin is a component for cycling through elements, like a carousel (slideshow). For a tutorial about Carousels, read our Bootstrap Carousel Tutorial. Note: Carousels are not supported properly in Internet Explorer 9 and earlier (because they use CSS3 transitions and animations to achieve the slide effect). <ol class="carousel-indicators"> <li data-target="#myCarousel" data-slide-to="0" class="active"></li> <li data-target="#myCarousel" data-slide-to="1"></li> <li data-target="#myCarousel" data-slide-to="2"></li> <li data-target="#myCarousel" data-slide-to="3"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="img_chania.jpg" alt="Chania"> </div> <div class="item"> <img src="img_chania2.jpg" alt="Chania"> </div> <div class="item"> <img src="img_flower.jpg" alt="Flower"> </div> <div class="item"> <img src="img_flower2.jpg" alt="Flower"> </div> </div> <!-- Left and right controls --> <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> Try it Yourself »
    Note: Carousels are not supported properly in Internet Explorer 9 and earlier (because they use CSS3 transitions and animations to achieve the slide effect).
    -->

    The Carousel Plugin Classes

    ClassDescription
    .carouselCreates a carousel
    .slideAdds a CSS transition and animation effect when sliding from one item to the next. Remove this class if you do not want this effect
    .carousel-indicatorsAdds indicators for the carousel. These are the little dots at the bottom of each slide (which indicates how many slides there are in the carousel, and which slide the user are currently viewing)
    .carousel-innerAdds slides to the carousel
    .icon-nextUnicode icon (arrow pointing right), used in carousels. This is often used instead of a glyphicon
    .icon-prevUnicode icon (arrow pointing left), used in carousels. This is often used instead of a glyphicon
    .itemSpecifies the content of each slide
    .left carousel-controlAdds a left button to the carousel, which allows the user to go back between the slides
    .right carousel-controlAdds a right button to the carousel, which allows the user to go forward between the slides
    .carousel-captionSpecifies a caption for the carousel

    Via data-* Attributes

    The data-ride="carousel" attribute activates the carousel. The data-slide and data-slide-to attributes specifies which slide to go to. The data-slide attribute accepts two values: prev or next, while data-slide-to accept numbers.

    Example

    <!-- Carousel --> <div id="myCarousel" class="carousel slide" data-ride="carousel"> <!-- Carousel Indicators --> <li data-target="#myCarousel" data-slide-to="1"></li> <!-- Carousel Controls --> <a class="left carousel-control" href="#myCarousel" data-slide="prev"> Try it Yourself »

    Via JavaScript

    Enable manually with:

    Example

    // Activate Carousel $("#myCarousel").carousel(); // Enable Carousel Indicators $(".item").click(function(){ $("#myCarousel").carousel(1); }); // Enable Carousel Controls $(".left").click(function(){ $("#myCarousel").carousel("prev"); }); Try it Yourself »

    Carousel Options

    Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-interval=".
    NameTypeDefaultDescriptionTry it
    intervalnumber, or the boolean false5000 Specifies the delay (in milliseconds) between each slide. Note: Set interval to false to stop the items from automatically slidingUsing JS Using data
    pausestring, or the boolean false"hover"Pauses the carousel from going through the next slide when the mouse pointer enters the carousel, and resumes the sliding when the mouse pointer leaves the carousel Note: Set pause to false to stop the ability to pause on hoverUsing JS Using data
    wrapbooleantrueSpecifies whether the carousel should go through all slides continuously, or stop at the last slide
  • true - cycle continuously
  • false - stop at the last item
  • Using JS Using data

    Carousel Methods

    The following table lists all available carousel methods.
    MethodDescriptionTry it
    .carousel(options)Activates the carousel with an option. See options above for valid valuesTry it
    .carousel("cycle")Goes through the carousel items from left to rightTry it
    .carousel("pause")Stops the carousel from going through itemsTry it
    .carousel(number)Goes to a specified item (zero-based: first item is 0, second item is 1, etc..)Try it
    .carousel("prev")Goes to the previous itemTry it
    .carousel("next")Goes to the next itemTry it

    Carousel Events

    The following table lists all available carousel events.
    EventDescriptionTry it
    slide.bs.carouselOccurs when the carousel is about to slide from one item to anotherTry it
    slid.bs.carouselOccurs when the carousel has finished sliding from one item to anotherTry it

    More Examples

    Captions to Slides

    Add <div class="carousel-caption"> within each <div class="item"> to create a caption for each slide:

    Example

    Chania

    The atmosphere in Chania has a touch of Florence and Venice.

    Chania

    The atmosphere in Chania has a touch of Florence and Venice.

    Flowers

    Beautiful flowers in Kolymbari, Crete.

    Flowers

    Beautiful flowers in Kolymbari, Crete. Previous Next <div id="myCarousel" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#myCarousel" data-slide-to="0" class="active"></li> <li data-target="#myCarousel" data-slide-to="1"></li> <li data-target="#myCarousel" data-slide-to="2"></li> <li data-target="#myCarousel" data-slide-to="3"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="img_chania.jpg" alt="Chania"> <div class="carousel-caption"> <h3>Chania</h3> <p>The atmosphere in Chania has a touch of Florence and Venice.</p> </div> </div> <div class="item"> <img src="img_chania2.jpg" alt="Chania"> <div class="carousel-caption"> <h3>Chania</h3> <p>The atmosphere in Chania has a touch of Florence and Venice.</p> </div> </div> <div class="item"> <img src="img_flower.jpg" alt="Flower"> <div class="carousel-caption"> <h3>Flowers</h3> <p>Beautiful flowers in Kolymbari, Crete.</p> </div> </div> <div class="item"> <img src="img_flower2.jpg" alt="Flower"> <div class="carousel-caption"> <h3>Flowers</h3> <p>Beautiful flowers in Kolymbari, Crete.</p> </div> </div> </div> <!-- Left and right controls --> <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> Try it Yourself »

    Bootstrap JS Collapse

    JS Collapse (collapse.js)

    Get base styles and flexible support for collapsible components like accordions and navigation. Plugin dependency: Collapse requires the transitions plugin to be included in your version of Bootstrap. For a tutorial about Collapsibles, read our Bootstrap Collapse Tutorial.

    The Collapse Plugin Classes

    ClassDescriptionExample
    .collapseHides the contentTry it
    .collapse inShows the contentTry it
    .collapsingAdded when the transition starts, and removed when it finishesTry it

    Via data-* Attributes

    Just add data-toggle="collapse" and a data-target to element to automatically assign control of a collapsible element. The data-target attribute accepts a CSS selector to apply the collapse to. Be sure to add the class collapse to the collapsible element. If you'd like it to default open, add the additional class in.

    Example

    <button class="btn" data-toggle="collapse" data-target="#demo">Collapsible</button> <div id="demo" class="collapse"> Some text.. </div> Try it Yourself » Tip: To add accordion-like group management to a collapsible control, add the data attribute data-parent="#selector".

    Via JavaScript

    Enable manually with: $('.collapse').collapse()

    Collapse Options

    Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-parent=".
    NameTypeDefaultDescription
    parentselectorfalseAll collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior - this is dependent on the panel class) - See example below
    togglebooleantrueToggles the collapsible element on invocation

    Collapse Methods

    The following table lists all available collapse methods.
    MethodDescriptionTry it
    .collapse(options)Activates the collapsible element with an option. See options above for valid values
    .collapse("toggle")Toggles the collapsible elementTry it
    .collapse("show")Shows the collapsible elementTry it
    .collapse("hide")Hides the collapsible elementTry it

    Collapse Events

    The following table lists all available collapse events.
    EventDescriptionTry it
    show.bs.collapseOccurs when the collapsible element is about to be shownTry it
    shown.bs.collapseOccurs when the collapsible element is fully shown (after CSS transitions have completed)Try it
    hide.bs.collapseOccurs when the collapsible element is about to be hiddenTry it
    hidden.bs.collapseOccurs when the collapsible element is fully hidden (after CSS transitions have completed)Try it

    More Examples

    Simple Collapsible

    The following example makes a button toggle the expanding and collapsing content of another element:

    Example

    <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo"> Simple collapsible </button> <div id="demo" class="collapse in"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </div> Try it Yourself »

    Collapsible Panel

    The following example shows a collapsible panel:

    Example

    <div class="panel-group"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#collapse1">Collapsible panel</a> </h4> </div> <div id="collapse1" class="panel-collapse collapse"> <div class="panel-body">Panel Body</div> <div class="panel-footer">Panel Footer</div> </div> </div> </div> Try it Yourself »

    Collapsible List Group

    The following shows a collapsible panel with a list group inside:

    Example

    <div class="panel-group"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#collapse1">Collapsible list group</a> </h4> </div> <div id="collapse1" class="panel-collapse collapse"> <ul class="list-group"> <li class="list-group-item">One</li> <li class="list-group-item">Two</li> <li class="list-group-item">Three</li> </ul> <div class="panel-footer">Footer</div> </div> </div> </div> Try it Yourself »

    Accordion

    The following example shows a simple accordion by extending the panel component: Note: The data-parent attribute makes sure that all collapsible elements under the specified parent will be closed when one of the collapsible item is shown.

    Example

    <div class="panel-group" id="accordion"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapse1"> Collapsible Group 1</a> </h4> </div> <div id="collapse1" class="panel-collapse collapse in"> <div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapse2"> Collapsible Group 2</a> </h4> </div> <div id="collapse2" class="panel-collapse collapse"> <div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapse3"> Collapsible Group 3</a> </h4> </div> <div id="collapse3" class="panel-collapse collapse"> <div class="panel-body">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div> </div> </div> </div> Try it Yourself »

    Expand and Collapse Toggle Icon & Text

    The following example changes the open/close text and icon when opening and closing the collapsible content:

    Example

    $(document).ready(function(){ $("#demo").on("hide.bs.collapse", function(){ $(".btn").html('<span class="glyphicon glyphicon-collapse-down"></span> Open'); }); $("#demo").on("show.bs.collapse", function(){ $(".btn").html('<span class="glyphicon glyphicon-collapse-up"></span> Close'); }); }); Try it Yourself » Or you can use CSS:

    Example

    /* Icon when the collapsible content is shown */ .btn:after { font-family: "Glyphicons Halflings"; content: "\e114"; } /* Icon when the collapsible content is hidden */ .btn.collapsed:after { content: "\e080"; } Try it Yourself »

    Bootstrap JS Dropdown

    JS Dropdown (dropdown.js)

    A dropdown menu is a toggleable menu that allows the user to choose one value from a predefined list. For a tutorial about Dropdowns, read our Bootstrap Dropdowns Tutorial.

    The Dropdown Plugin Classes

    ClassDescriptionExample
    .dropdownIndicates a dropdown menuTry it
    .dropdown-menuBuilds the dropdown menuTry it
    .dropdown-menu-rightRight-aligns a dropdown menuTry it
    .dropdown-headerAdds a header inside the dropdown menuTry it
    .dropupIndicates a dropup menuTry it
    .disabledDisables an item in the dropdown menuTry it
    .dividerSeparates items inside the dropdown menu with a horizontal lineTry it

    Via data-* Attributes

    Add data-toggle="dropdown" to a link or a button to toggle a dropdown menu.

    Example

    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown Example</a> Try it Yourself »

    Via JavaScript

    Enable manually with:

    Example

    $('.dropdown-toggle').dropdown(); Try it Yourself » Note: The data-toggle="dropdown" attribute is required regardless of whether you call the dropdown() method.

    Dropdown Options

    None

    Dropdown Methods

    The following table lists all available dropdown methods.
    MethodDescriptionTry it
    .dropdown("toggle")Toggles the dropdownTry it

    Dropdown Events

    The following table lists all available dropdown events.
    EventDescriptionTry it
    show.bs.dropdownOccurs when the dropdown is about to be shown.Try it
    shown.bs.dropdownOccurs when the dropdown is fully shown (after CSS transitions have completed)Try it
    hide.bs.dropdownOccurs when the dropdown is about to be hiddenTry it
    hidden.bs.dropdownOccurs when the dropdown is fully hidden (after CSS transitions have completed)Try it
    Tip: Use jQuery's event.relatedTarget to get the element which triggered the dropdown:

    Example

    $(".dropdown").on("show.bs.dropdown", function(event){ var x = $(event.relatedTarget).text(); // Get the text of the element alert(x); }); Try it Yourself »

    More Examples

    Change the caret icon to upside down

    The following example changes the caret icon from pointing downwards to upwards when clicking on the dropdown:

    Example

    /* CSS: */ <style> .caret.caret-up { border-top-width: 0; border-bottom: 4px solid #fff; } </style> /* JS: */ <script> $(document).ready(function(){ $(".dropdown").on("hide.bs.dropdown", function(){ $(".btn").html('Dropdown <span class="caret"></span>'); }); $(".dropdown").on("show.bs.dropdown", function(){ $(".btn").html('Dropdown <span class="caret caret-up"></span>'); }); }); </script> Try it Yourself »

    Navbar With Dropdown

    The following example adds a dropdown menu for a button in the navigation bar:

    Example

    <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a> </div> <div> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="#">Page 1-1</a></li> <li><a href="#">Page 1-2</a></li> <li><a href="#">Page 1-3</a></li> </ul> </li> <li><a href="#">Page 2</a></li> <li><a href="#">Page 3</a></li> </ul> </div> </div> </nav> Try it Yourself » The following example adds a dropdown menu with a login form in the navbar:

    Example

    <ul class="nav navbar-nav navbar-right"> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">Login <span class="glyphicon glyphicon-log-in"></span></a> <div class="dropdown-menu"> <form id="formlogin" class="form container-fluid"> <div class="form-group"> <label for="usr">Name:</label> <input type="text" class="form-control" id="usr"> </div> <div class="form-group"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd"> </div> <button type="button" id="btnLogin" class="btn btn-block">Login</button> </form> <div class="container-fluid"> <a class="small" href="#">Forgot password?</a> </div> </div> </li> </ul> Try it Yourself »

    Multi-Level Dropdowns

    In this example, we use jQuery to open multi-level dropdowns on click:

    Example

    <script> $(document).ready(function(){ $('.dropdown-submenu a.test').on("click", function(e){ $(this).next('ul').toggle(); e.stopPropagation(); e.preventDefault(); }); }); </script> Try it Yourself » In this example, we have created a custom .dropdown-submenu class for multi-level dropdowns:

    Example

    /* CSS: */ <style> .dropdown-submenu { position: relative; } .dropdown-submenu .dropdown-menu { top: 0; left: 100%; margin-top: -1px; } </style> /* JS: */ <script> $(document).ready(function(){ $('.dropdown-submenu a.test').on("click", function(e){ $(this).next('ul').toggle(); e.stopPropagation(); e.preventDefault(); }); }); </script> Try it Yourself »

    Bootstrap JS Modal

    JS Modal (modal.js)

    The Modal plugin is a dialog box/popup window that is displayed on top of the current page. For a tutorial about Modals, read our Bootstrap Modal Tutorial. <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button> <!-- Modal --> <div id="myModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <!-- Modal Header --> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Modal Header</h4> </div> <!-- Modal Body --> <div class="modal-body"> <p>Some text in the modal.</p> </div> <!-- Modal Footer --> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> Try it Yourself » -->

    The Modal Plugin Classes

    ClassDescription
    .modalCreates a modal
    .modal-contentStyles the modal properly with border, background-color, etc. Use this class to add the modal's header, body, and footer.
    .modal-headerDefines the style for the header of the modal
    .modal-bodyDefines the style for the body of the modal
    .modal-footerDefines the style for the footer in the modal. Note: This area is right-aligned by default. To change this, overwrite CSS with text-align:left|center
    .modal-smSpecifies a small modal
    .modal-lgSpecifies a large modal
    .fadeAdds an animation/transition effect which fades the modal in and out

    Trigger the Modal Via data-* Attributes

    Add data-toggle="modal" and data-target="#modalID" to any element. Note: For <a> elements, omit data-target, and use href="#modalID" instead:

    Example

    <!-- Buttons --> <button type="button" data-toggle="modal" data-target="#myModal">Open Modal</button> <!-- Links --> <a data-toggle="modal" href="#myModal">Open Modal</a> <!-- Other elements --> <p data-toggle="modal" data-target="#myModal">Open Modal</p> Try it Yourself »

    Trigger Via JavaScript

    Enable manually with:

    Example

    $("#myModal").modal() Try it Yourself »

    Modal Options

    Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-backdrop=".
    NameTypeDefaultDescriptionTry it
    backdropboolean or the string "static"true Specifies whether the modal should have a dark overlay:
  • true - dark overlay
  • false - no overlay (transparent)
  • If you specify the value "static", it is not possible to close the modal when clicking outside of it
    Using JS Using data
    keyboardbooleantrueSpecifies whether the modal can be closed with the escape key (Esc):
  • true - the modal can be closed with Esc
  • false - the modal cannot be closed with Esc
  • Using JS Using data
    showbooleantrueSpecifies whether to show the modal when initializedUsing JS Using data

    Modal Methods

    The following table lists all available modal methods.
    MethodDescriptionTry it
    .modal(options)Activates the content as a modal. See options above for valid valuesTry it
    .modal("toggle")Toggles the modalTry it
    .modal("show")Opens the modalTry it
    .modal("hide")Hides the modalTry it

    Modal Events

    The following table lists all available modal events.
    EventDescriptionTry it
    show.bs.modalOccurs when the modal is about to be shownTry it
    shown.bs.modalOccurs when the modal is fully shown (after CSS transitions have completed)Try it
    hide.bs.modalOccurs when the modal is about to be hiddenTry it
    hidden.bs.modalOccurs when the modal is fully hidden (after CSS transitions have completed)Try it

    More Examples

    Login Modal

    The following example creates a modal for login:

    Example

    <div class="container"> <h2>Modal Login Example</h2> <!-- Trigger the modal with a button --> <button type="button" class="btn btn-default btn-lg" id="myBtn">Login</button> <!-- Modal --> <div class="modal fade" id="myModal" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 style="color:red;"><span class="glyphicon glyphicon-lock"></span> Login</h4> </div> <div class="modal-body"> <form role="form"> <div class="form-group"> <label for="usrname"><span class="glyphicon glyphicon-user"></span> Username</label> <input type="text" class="form-control" id="usrname" placeholder="Enter email"> </div> <div class="form-group"> <label for="psw"><span class="glyphicon glyphicon-eye-open"></span> Password</label> <input type="text" class="form-control" id="psw" placeholder="Enter password"> </div> <div class="checkbox"> <label><input type="checkbox" value="" checked>Remember me</label> </div> <button type="submit" class="btn btn-default btn-success btn-block"><span class="glyphicon glyphicon-off"></span> Login</button> </form> </div> <div class="modal-footer"> <button type="submit" class="btn btn-default btn-default pull-left" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button> <p>Not a member? <a href="#">Sign Up</a></p> <p>Forgot <a href="#">Password?</a></p> </div> </div> </div> </div> </div> Try it Yourself »

    Bootstrap JS Popover

    JS Popover (popover.js)

    The Popover plugin is similar to tooltips; it is a pop-up box that appears when the user clicks on an element. The difference is that the popover can contain much more content. Plugin dependency: Popovers require the tooltip plugin (tooltip.js) to be included in your version of Bootstrap. For a tutorial about Popovers, read our Bootstrap Popover Tutorial.

    Via data-* Attributes

    The data-toggle="popover" activates the popover. The title attribute specifies the header text of the popover. The data-content attribute specifies the text that should be displayed inside the popover's body.

    Example

    <a href="#" data-toggle="popover" title="Popover Header" data-content="Some content inside the popover">Toggle popover</a> Try it Yourself »

    Via JavaScript

    Popovers are not CSS-only plugins, and must therefore be initialized with jQuery: select the specified element and call the popover() method.

    Example

    // Select all elements with data-toggle="popover" in the document $('[data-toggle="popover"]').popover(); // Select a specified element $('#myPopover').popover(); Try it Yourself »

    Popover Options

    Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-placement=".
    NameTypeDefaultDescriptionTry it
    animationbooleantrue Specifies whether to add a CSS fade transition effect when opening and closing the popover
  • true - Add a fading effect
  • false - Do not add a fading effect
  • Try it
    containerstring, or the boolean falsefalseAppends the popover to a specific element. Example: container: 'body'Try it
    contentstring"Specifies the text inside the popover's bodyTry it
    delaynumber, or object0Specifies the number of milliseconds it will take to open and close the popover. To specify a delay for opening and another one for closing, use the object structure: delay: {show: 500, hide: 100} - which will take 500 ms to open the popover, but only 100 ms to close itTry it
    htmlboolean falseSpecifies whether to accept HTML tags in the popover:
  • true - Accept HTML tags
  • false - Do not accept HTML tags
  • Note: The HTML must be inserted in the title attribute (or using the title option). When set to false (default), jQuery's text() method will be used. Use this if you are worried about XSS attacks
    Try it
    placementstring"right"Specifies the popover position. Possible values:
  • "top" - Popover on top
  • "bottom" - Popover on bottom
  • "left" - Popover on left
  • "right" - Popover on right
  • "auto" - Lets the browser decide the position of the popover. For example, if the value is "auto left", the popover will display on the left side when possible, otherwise on the right. If the value is "auto bottom", the popover will display at the bottom when possible, otherwise on the top
  • Try it
    selectorstring, or the boolean falsefalseAdds the popover to a specified selectorTry it
    templatestring Base HTML to use when creating the popover. The popover's title will be injected into the .popover-title. The popover's content will be injected into the .popover-content. .arrow will become the popover's arrow. The outermost wrapper element should have the .popover class.
    titlestring"Specifies the header text of the popoverTry it
    triggerstring"click"Specifies how the popover is triggered. Possible values:
  • "click" - Trigger the popover with a click
  • "hover" - Trigger the popover on hover
  • "focus" - Trigger the popover when it gets focus (by tabbing or clicking .e.g)
  • "manual" - Trigger the popover manually
  • Tip: To pass multiple values, separate them with a space
    Try it
    viewportstring, or object{selector: "body", padding: 0}Keeps the popover within the bounds of this element. Example: viewport: '#viewport' or {selector: '#viewport', padding: 0}

    Popover Methods

    The following table lists all available popover methods.
    MethodDescriptionTry it
    .popover(options)Activates the popover with an option. See options above for valid valuesTry it
    .popover("show")Shows the popoverTry it
    .popover("hide")Hides the popoverTry it
    .popover("toggle")Toggles the popoverTry it
    .popover("destroy")Hides and destroys the popoverTry it

    Popover Events

    The following table lists all available popover events.
    EventDescriptionTry it
    show.bs.popover Occurs when the popover is about to be shownTry it
    shown.bs.popover Occurs when the popover is fully shown (after CSS transitions have completed)Try it
    hide.bs.popover Occurs when the popover is about to be hiddenTry it
    hidden.bs.popover Occurs when the popover is fully hidden (after CSS transitions have completed)Try it

    More Examples

    Custom Popover Design

    Use CSS to customize the look of the popover:

    Example

    /* Popover */ .popover { border: 2px dotted red; } /* Popover Header */ .popover-title { background-color: #73AD21; color: #FFFFFF; font-size: 28px; text-align:center; } /* Popover Body */ .popover-content { background-color: coral; color: #FFFFFF; padding: 25px; } /* Popover Arrow */ .arrow { border-right-color: red !important; } Try it Yourself »

    Bootstrap JS Scrollspy

    JS Scrollspy (scrollspy.js)

    The Scrollspy plugin is used to automatically update links in a navigation list based on scroll position. For a tutorial about Scrollspy, read our Bootstrap Scrollspy Tutorial. Tip: The Scrollspy plugin is often used together with the Affix plugin.

    Via data-* Attributes

    Add data-spy="scroll" to the element that should be used as the scrollable area (often this is the <body> element). Then add the data-target attribute with a value of the id or the class name of the navigation bar (.navbar). This is to make sure that the navbar is connected with the scrollable area. Note that scrollable elements must match the ID of the links inside the navbar's list items (<div id="section1"> matches <a href="#section1">). The optional data-offset attribute specifies the number of pixels to offset from top when calculating the position of scroll. This is useful when you feel that the links inside the navbar changes the active state too soon or too early when jumping to the scrollable elements. Default is 10 pixels. Requires relative positioning: The element with data-spy="scroll" requires the CSS position property, with a value of "relative" to work properly.

    Example

    <!-- The scrollable area --> <body data-spy="scroll" data-target=".navbar" data-offset="50"> <!-- The navbar - The <a> elements are used to jump to a section in the scrollable area --> <nav class="navbar navbar-inverse navbar-fixed-top"> ... <ul class="nav navbar-nav"> <li><a href="#section1">Section 1</a></li> ... </nav> <!-- Section 1 --> <div id="section1"> <h1>Section 1</h1> <p>Try to scroll this page and look at the navigation bar while scrolling!</p> </div> ... </body> Try it Yourself »

    Via JavaScript

    Enable manually with:

    Example

    $('body').scrollspy({target: ".navbar"}) Try it Yourself »

    Scrollspy Options

    Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-offset=".
    NameTypeDefaultDescriptionTry it
    offsetnumber10 Specifies the number of pixels to offset from top when calculating the position of scrollTry it

    Scrollspy Methods

    The following table lists all available scrollspy methods.
    MethodDescriptionTry it
    .scrollspy("refresh")When adding and removing elements from the scrollspy, this method can be used to refresh the documentTry it

    Scrollspy Events

    The following table lists all available scrollspy events.
    EventDescriptionTry it
    activate.bs.scrollspyOccurs when a new item becomes activated by the scrollspyTry it

    More Examples

    Scrollspy with animated scroll

    How to add a smooth page scroll to an anchor on the same page:

    Smooth scrolling

    // Add scrollspy to <body> $('body').scrollspy({target: ".navbar", offset: 50}); // Add smooth scrolling on all links inside the navbar $("#myNavbar a").on('click', function(event) { // Make sure this.hash has a value before overriding default behavior if (this.hash !== ") { // Prevent default anchor click behavior event.preventDefault(); // Store hash var hash = this.hash; // Using jQuery's animate() method to add smooth page scroll // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area $('html, body').animate({ scrollTop: $(hash).offset().top }, 800, function(){ // Add hash (#) to URL when done scrolling (default click behavior) window.location.hash = hash; }); } // End if }); Try it Yourself »

    Scrollspy & Affix

    Using the Affix plugin together with the Scrollspy plugin:

    Horizontal Menu (Navbar)

    <body data-spy="scroll" data-target=".navbar" data-offset="50"> <nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="197"> ... </nav> </body> Try it Yourself »

    Vertical Menu (Sidenav)

    <body data-spy="scroll" data-target="#myScrollspy" data-offset="15"> <nav class="col-sm-3" id="myScrollspy"> <ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="205"> ... </nav> </body> Try it Yourself »

    Bootstrap JS Tab

    JS Tab (tab.js)

    Tabs are used to separate content into different panes where each pane is viewable one at a time. For a tutorial about Tabs, read our Bootstrap Tabs/Pills Tutorial.

    The Tab Plugin Classes

    ClassDescriptionExample
    .nav nav-tabsCreates navigation tabsTry it
    .nav-justifiedMakes navigation tabs/pills equal widths of their parent, at screens wider than 768px. On smaller screens, the nav tabs are stackedTry it
    .tab-contentTogether with .tab-pane and data-toggle="tab", it makes the tab toggleableTry it
    .tab-paneTogether with .tab-content and data-toggle="tab", it makes the tab toggleableTry it

    Via data-* Attributes

    Add data-toggle="tab" to each tab, and add a .tab-pane class with a unique ID for every tab and wrap them in a .tab-content class.

    Example

    <ul class="nav nav-tabs"> <li class="active"><a data-toggle="tab" href="#home">Home</a></li> <li><a data-toggle="tab" href="#menu1">Menu 1</a></li> </ul> <div class="tab-content"> <div id="home" class="tab-pane fade in active"> <h3>HOME</h3> <p>Some content.</p> </div> <div id="menu1" class="tab-pane fade"> <h3>Menu 1</h3> <p>Some content in menu 1.</p> </div> </div> Try it Yourself »

    Via JavaScript

    Enable manually with:

    Example

    // Select all tabs $('.nav-tabs a').click(function(){ $(this).tab('show'); }) // Select tab by name $('.nav-tabs a[href="#home"]').tab('show') // Select first tab $('.nav-tabs a:first').tab('show') // Select last tab $('.nav-tabs a:last').tab('show') // Select fourth tab (zero-based) $('.nav-tabs li:eq(3) a').tab('show') Try it Yourself »

    Tab Options

    None

    Tab Methods

    The following table lists all available tab methods.
    MethodDescriptionTry it
    .tab("show")Shows the tabTry it

    Tab Events

    The following table lists all available tab events.
    EventDescriptionTry it
    show.bs.tabOccurs when the tab is about to be shown.Try it
    shown.bs.tabOccurs when the tab is fully shown (after CSS transitions have completed)Try it
    hide.bs.tabOccurs when the tab is about to be hiddenTry it
    hidden.bs.tabOccurs when the tab is fully hidden (after CSS transitions have completed)Try it
    Tip: Use jQuery's event.target and event.relatedTarget to get the active tab and the previous active tab:

    Example

    $('.nav-tabs a').on('shown.bs.tab', function(event){ var x = $(event.target).text(); // active tab var y = $(event.relatedTarget).text(); // previous tab }); Try it Yourself »

    Bootstrap JS Tooltip

    JS Tooltip (tooltip.js)

    The Tooltip plugin is small pop-up box that appears when the user moves the mouse pointer over an element. For a tutorial about Tooltips, read our Bootstrap Tooltip Tutorial.

    Via data-* Attributes

    The data-toggle="tooltip" activates the tooltip. The title attribute specifies the text that should be displayed inside the tooltip.

    Example

    <a href="#" data-toggle="tooltip" title="Hooray!">Hover over me</a> Try it Yourself »

    Via JavaScript

    Tooltips are not CSS-only plugins, and must therefore be initialized with jQuery: select the specified element and call the tooltip() method.

    Example

    // Select all elements with data-toggle="tooltips" in the document $('[data-toggle="tooltip"]').tooltip(); // Select a specified element $('#myTooltip').tooltip(); Try it Yourself »

    Tooltip Options

    Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-placement=".
    NameTypeDefaultDescriptionTry it
    animationbooleantrue Specifies whether to add a CSS fade transition effect when showing and hiding the tooltip
  • true - Add a fading effect
  • false - Do not add a fading effect
  • Try it
    containerstring, or the boolean falsefalseAppends the tooltip to a specific element. Example: container: 'body'Try it
    delaynumber, or object0Specifies the number of milliseconds it will take to show and hide the tooltip. To specify a delay for showing and another one for hiding, use the object structure: delay: {show: 500, hide: 100} - which will take 500 ms to show the tooltip, but only 100 ms to hide itTry it
    htmlboolean falseSpecifies whether to accept HTML tags in the tooltip:
  • true - Accept HTML tags
  • false - Do not accept HTML tags
  • Note: The HTML must be inserted in the title attribute (or using the title option). When set to false (default), jQuery's text() method will be used. Use this if you are worried about XSS attacks
    Try it
    placementstring"top"Specifies the tooltip position. Possible values:
  • "top" - Tooltip on top
  • "bottom" - Tooltip on bottom
  • "left" - Tooltip on left
  • "right" - Tooltip on right
  • "auto" - Lets the browser decide the position of the tooltip. For example, if the value is "auto left", the tooltip will display on the left side when possible, otherwise on the right. If the value is "auto bottom", the tooltip will display at the bottom when possible, otherwise on the top
  • Try it
    selectorstring, or the boolean falsefalseAdds the tooltip to a specified selectorTry it
    templatestring Base HTML to use when creating the tooltip. The tooltip's title will be inserted into the element having the class .tooltip-inner and the element with the class .tooltip-arrow will become the tooltip's arrow. The outermost wrapper element should have the .tooltip class.
    titlestring""Specifies the text that should be displayed inside the tooltipTry it
    triggerstring"hover focus"Specifies how the tooltip is triggered. Possible values:
  • "click" - Trigger the tooltip with a click
  • "hover" - Trigger the tooltip on hover
  • "focus" - Trigger the tooltip when it gets focus (by tabbing or clicking .e.g)
  • "manual" - Trigger the tooltip manually
  • Tip: To pass multiple values, separate them with a space
    Try it
    viewportstring, or object{selector: "body", padding: 0}Keeps the tooltip within the bounds of this element. Example: viewport: '#viewport' or {selector: '#viewport', padding: 0}

    Tooltip Methods

    The following table lists all available tooltip methods.
    MethodDescriptionTry it
    .tooltip(options)Activates the tooltip with an option. See options above for valid valuesTry it
    .tooltip("show")Shows the tooltipTry it
    .tooltip("hide")Hides the tooltipTry it
    .tooltip("toggle")Toggles the tooltipTry it
    .tooltip("destroy")Hides and destroys the tooltipTry it

    Tooltip Events

    The following table lists all available tooltip events.
    EventDescriptionTry it
    show.bs.tooltipOccurs when the tooltip is about to be shownTry it
    shown.bs.tooltipOccurs when the tooltip is fully shown (after CSS transitions have completed)Try it
    hide.bs.tooltipOccurs when the tooltip is about to be hiddenTry it
    hidden.bs.tooltipOccurs when the tooltip is fully hidden (after CSS transitions have completed)Try it

    More Examples

    Custom Tooltip Design

    Use CSS to customize the look of the tooltip:

    Example

    /* Tooltip */ .test + .tooltip > .tooltip-inner { background-color: #73AD21; color: #FFFFFF; border: 1px solid green; padding: 15px; font-size: 20px; } /* Tooltip on top */ .test + .tooltip.top > .tooltip-arrow { border-top: 5px solid green; } /* Tooltip on bottom */ .test + .tooltip.bottom > .tooltip-arrow { border-bottom: 5px solid blue; } /* Tooltip on left */ .test + .tooltip.left > .tooltip-arrow { border-left: 5px solid red; } /* Tooltip on right */ .test + .tooltip.right > .tooltip-arrow { border-right: 5px solid black; } Try it Yourself »