Bootstrap is the most popular CSS framework option when it comes to dealing with responsive, mobile-first front-end web development. Moreover, it is free and open-source.
Launched in 2011, Bootstrap has all the CSS and JS-based design templates that one requires for building buttons, forms, navigation, typography, and other interface components.
Bootstrap Interview Questions
There is a pretty good chance of a web development job interview to feature Bootstrap-based questions. So, you need to keep up your Bootstrap preparation to grab the role. To help you with the cause, here are 20 important Bootstrap interview questions with answers:
Q: What do you mean by the Bootstrap Grid System?
A: The Bootstrap Grid System is a responsive, mobile-first system that scales up to 12 columns as per the increase in the device or viewport size. The system features predefined classes for easy layout options and powerful mix-ins for generating effectively semantic layouts.
Q: Please explain Normalize in Bootstrap.
A: For establishing cross-browser consistency, Bootstrap makes use of Normalize. It is a small CSS file capable of offering better cross-browser consistency in the default styling of HTML elements. Also, Normalize.css is an HTML5-ready and modern alternative to CSS resets.
Q: Can you enumerate the various lists supported by Bootstrap?
A: Following are the three types of lists supported by Bootstrap:
- Definition Lists – This type of list allows each list item to have both the <dt> and the <dd> elements. The <dt> denotes definition term, which is the term or phrase being defined. The <dd> element contains the definition for the <dt> element.
- Ordered Lists – This type of list follows some kind of sequential order. Also, it is prefaced by numbers.
- Unordered Lists – Traditionally styled with bullets, an unordered list doesn’t follow any particular order. Using the .list-unstyled class allows removing the bullets styling from the unordered list. For placing all list items on a single line, the .list-inline class can be used.
Q: What do you mean by Glyphicons? How do you use them?
A: Glyphicons are icon fonts that are used in web projects. Although Glyphicons Halflings aren’t free and require licensing in general, they are available free of cost for Bootstrap projects. Add the following code anywhere you wish to use the Glyphicons:
<span class = “glyphicon glyphicon-search”></span>
Note: – For proper padding, it is advised to leave a space between the icon and the text.
Q: Could you explain how to use the Dropdown plugin in Bootstrap?
A: There are three ways of toggling the dropdown plugin’s hidden content in Bootstrap:
- With data attributes – Add data-toggle = “dropdown” to some button or link to toggle a dropdown. For example,
<div class = "dropdown"> <a data-toggle = "dropdown" href = "#">Dropdown trigger</a> <ul class = "dropdown-menu" role = "menu" aria-labelledby = "dLabel"> ... </ul> </div> </pre.
<div class = "dropdown"> <a id = "dLabel" role = "button" data-toggle = "dropdown" data-target = "#" href = "/somepage.html"> Dropdown <span class = "caret"></span> </a> <ul class = "dropdown-menu" role = "menu" aria-labelledby = "dLabel"> ... </ul> </div>
Q: Please provide an explanation on input groups in Bootstrap.
A: Input groups are simply extended Form Controls in Bootstrap. One can easily append and prepend buttons or text to the text-based inputs using the input groups. Appending and prepending content to an input field allows adding common elements to the user input.
You can append or prepend elements to a .form-control by:
- Wrapping it in a <div> element with the class .input-group
- With the same <div> element, put the extra content inside a <span> element with the .input-group-addon class
- Finally, place the <span> element before or after the <input> element as required
Q: How will you create a tabbed, pills, and vertical pills navigation menu in Bootstrap?
- For creating a tabbed navigation menu
- Start with a basic unordered list with the .nav base class
- Now, add the .nav-tabs class
- For creating a pills navigation menu
- Start with a basic unordered list with the .nav base class
- Now, add the .nav-pills class
- For creating a vertical pills navigation menu
- Stack the pills vertically using the .nav-stacked class
- Now, add the .nav and .nav-pills classes
Q: What do you understand by Bootstrap navbar? How will you create one?
A: One of the most prominent features of Bootstrap, a navbar is a responsive ‘meta’ component that serves as a navigation header for an application or website. There can be several navbars in an application or website.
In mobile views, a navbar collapses and becomes horizontal when the available viewport width increases. The navbar includes styling for basic navigation and site names. Here is how to create a navbar in Bootstrap:
- Add the .navbar and .navbar-default classes to the <nav> tag
- Next, add role = “navigation” to the <nav> element
- Now, add .navbar-header, a header class, to the <div> element. For making the text slightly larger, include an <a> element with the navbar-brand class
- Add an unordered list with .nav and .navbar-nav classes for adding links to the Bootstrap navbar
Q: Can you explain Bootstrap breadcrumb?
A: A Bootstrap breadcrumb is a great way to display hierarchy-based information for a website. Simply, it is an unordered list with a .breadcrumb class. CSS automatically adds the separator for a Bootstrap breadcrumb.
In blogs, the breadcrumb can display categories, publishing dates, or tags. It indicates the present page’s location within a navigational hierarchy.
Q: How do you create and customize thumbnails in Bootstrap?
A: For creating thumbnails using Bootstrap, add a <a> tag with .thumbnail class around an image. It will add four pixels of padding as well as a gray border. When hovered, an animated glow outlines the image.
You can add any type of HTML content, such as buttons, headings, or paragraphs, into thumbnails. This is how to customize thumbnails using Bootstrap:
- Change the <a> tag with .thumbnail class to a <div> tag
- Add anything that you need inside the <div> tag. You can use the default span-based naming convention for sizing
Note: – If you wish to group multiple images then place them in an unordered list. Each list item will be floated to the left.
Q: Please explain Bootstrap alerts. Also, tell how you will create a Bootstrap Dismissal Alert.
A: Used for styling messages to the user, Bootstrap Alerts provide contextual feedback messages for typical user actions. To create a Bootstrap Dismissal Alert:
- Create a wrapper <div> and add a .alert class and one of the 4 contextual classes, namely .alert-danger, .alert-info, .alert-success, and .alert-warning, for adding a basic alert
- Add the optional .alert-dismissbale class to the <div>
- Next, add a close button
- Finally, use the <button> element with the data-dismiss = “alert” data attribute
Q: Can you explain how to create an alternate and a striped progress bar using Bootstrap?
For creating a progress bar with various styles:
- Add a <div> with a .progress class
- Inside the <div>, add an empty <div> with a .progress-bar class and a progress-bar-* class (* can be danger, info, success, or warning)
- Lastly, add a style attribute with the width expressed as a percentage. E.g., style = “80%”
For creating a striped progress bar:
- Add a <div> with .progress and .progress-striped classes
- Inside the <div>, add an empty <div> with a .progress-bar class and progress-bar-* class, where * can be any of the danger, info, success, or warning
- Now, add a style attribute with the width being expressed as a percentage, E.g., style = “70%”
Q: What do you understand by Bootstrap media objects?
A: Bootstrap media objects are abstract object styles for building different types of components, such as blog comments and Tweets, which feature either a left-aligned or right-aligned image and textual content.
The main aim of a Bootstrap media object is to make code required for developing blocks of information incredibly smaller. In order to achieve easy extensibility, lightweight markup, and other desirable aspects, classes are applied to some of the simple markups.
Q: What purposes do the .media and .useful classes serve in Bootstrap?
A: The .media class allows a media object, such as audio, images, or video, to float to the left or right of a content block. For adding article lists or comment threads to an unordered list, we use the .useful class.
Q: Do you know what Bootstrap panels are? Also, explain how to create a Bootstrap panel with a heading.
A: Bootstrap panel components are used for putting your DOM component in a box. To get a basic panel, simply add .panel and .panel-default classes to the <div> element. There are two ways of adding panel heading to a Bootstrap panel:
- Use any of the <h1>, <h2>, <h3>, <h4>, <h5>, or <h6> tags with a .panel-title class (Adds a pre-styled heading)
- Use the .panel-heading class (Adds a heading container to the panel)
Q: Can you explain the purpose of the Scrollspy plugin?
A: Using the Scrollspy plugin in Bootstrap allows you to target certain sections of the page based on the scroll position. Thereafter, you can add .active classes, based on the scroll position, to the Bootstrap navbar.
Q: Please enumerate the various contextual classes available for styling the panels in Bootstrap.
A: Various contextual classes used in Bootstrap for styling the panels, i.e. making them more meaningful, are:
Q: Is it possible to put a table within the Bootstrap panel?
A: Yes, it is possible to put a table within a Bootstrap panel. Use the .table class within a panel to get a non-bordered table within the same.
Note: – If there is an <div> element containing .panel-body class then we need to add an extra border to the top of the table for clearly defined separation. In case there is no <div> element containing the aforementioned class then the component moves from the panel header to the table without any issues.
Q: What do you mean by Bootstrap well?
A: In order to make the content appear sunken or adding an inset effect to a webpage, we use the Bootstrap well. In actuality, it is a container in <div>.
In order to create a Bootstrap well, simply wrap the entire content that you want to appear in the Bootstrap well with a <div> containing the .well class.
Q: Why do we use the affix plugin in Bootstrap?
A: We use the affix plugin in Bootstrap for affixing a <div> to some certain location on a webpage. The plugin also allows toggling pinning on and off for the affixed <div>. Social icons are the most popular example of using the affix plugin in Bootstrap.
Note: – The affixed <div> starts from a particular location on the webpage and scrolls with it. However, after a certain mark, it will be locked in place, thus stopping scrolling with the rest of the webpage.
So, that completes the list of 20 Important Bootstrap Interview Questions list. Hope you find them useful in preparing for your upcoming Bootstrap interview. All the best!
Looking to further your Bootstrap knowledge? Try these best Bootstrap tutorials recommended by the community today!