Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Starter Files
3.
Use of Doctype
4.
Mobile First Application
5.
Typography and Links
6.
Normalize
7.
Containers
8.
Frequently Asked Questions
8.1.
What is Bootstrap?
8.2.
What is meant by CSS?
8.3.
What is the use of CSS?
8.4.
What is the difference between Bootstrap and CSS?
8.5.
What are the disadvantages of using Bootstrap?
9.
Conclusion
Last Updated: Mar 27, 2024

Bootstrap CSS Overview

Author Abhay Trivedi
0 upvote

Introduction

Bootstrap is an open-source CSS framework making it easy to create attractive web pages with responsiveness. These CSS and javascript-based design templates for forms, buttons, and typography are contained in bootstrap. 

Introduction

In this article, we discuss Bootstrap CSS Overview and the main things that come with it. How and why do we use Containers? Why should we use Normalise to ensure cross-platform consistency? Why is it essential to make a website responsive and a mobile-first approach, and more?

Starter Files

Include the following link in the <head> element to use Bootstrap.

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">


Along with this, to add functionality to your website, you should have to include the following script tags before the </body> as well.

<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>


After adding the above links, your HTML document looks like this now:

HTML file

Use of Doctype

DOCTYPE is an abbreviation of Document Type Declaration. The <!DOCTYPE> declaration indicates the document type and assists browsers to display web pages appropriately.

It must appear just once, at the top of the page (before any HTML tags). Every HTML document must begin with a <!DOCTYPE> declaration. Declaration of Doctype in HTML5 is done as follows:

<!DOCTYPE html>


Since the declaration of <!DOCTYPE> tag is NOT case-sensitive; the below declarations are valid:

<!DOCTYPE html> 
<!DocType html>
<!Doctype html>
<!doctype html>


Bootstrap makes use of this Doctype tag, hence we must include HTML5 doctype at the beginning of all your Bootstrap projects. 

Mobile First Application

Bootstrap 2 added optional mobile-friendly styles. But Bootstrap 3 rewrite the project to be mobile-friendly throughout. Instead of counting on optional mobile techniques, they're baked right into the core. Bootstrap is now mobile-first, and you can find styles throughout the library instead of in separate files. Bootstrap 4 was released in 2018 and provides more faster stylesheet and responsive design. Along with that bootstrap 5 is the most recent version which is used for mainly mobile first applications.

We need to add a meta tag with a name viewport in the <head> section of your HTML code. It helps in providing touch zooming and easy rendering in mobile devices. The syntax to be included is mentioned below:

<meta name = "viewport" content = "width = device-width, initial-scale = 1.0">


Sometimes we just need to add only scroll capabilities instead of zooming. So, for that you need to assign “NO” value to user-scalable attribute with the above given meta tag syntax as follows:

<meta name = "viewport" content = "width=device-width, initial-scale = 1.0, maximum-scale = 1, user-scalable = no">


Doing this helps us in disabling zooming abilities. But overall, It is not an excellent idea to use it on every site, so use caution!

Typography and Links

Typography is the art & style of arranging letters and characters to form words and sentences which are legible, clear, and visually appealing to the reader. Typography involves font style, appearance, and structure, including typefaces, sizes, line lengths, line-spacing, letter-spacing, and the space between pairs of letters that aim to elicit specific emotions and convey precise messages.

Bootstrap Typography helps you create and style different inline elements like headings, paragraphs, abbreviations, blockquotes, lists, etc. It also helps in setting basic global display by specifying the background color = #fff.

Normalize

To ensure whether the content on your web page is consistent or not across different browsers, we use Normalize in Bootstrap. In other words, Bootstrap uses Normalize for establishing cross-browser consistency. Normalize in bootstrap is a small-sized CSS file. It is a good alternative to the HTML5. Normalize CSS also provide stability for doing default styling using HTML elements.

Containers

container

To wrap a webpage's content and easily center the content's use class .container as shown below. The .container class in the bootstrap.css file may look like this.

.container {
   padding-right: 20px;
   padding-left: 20px;
   margin-right: auto;
   margin-left: auto;
}

@media (min-width: 525px) {
   .container {
      width: 100%;
   }
}

<div class = "container">
   ...
</div>

Note - Due to padding & fixed widths, containers are not nestable by default.

Here you can see that CSS has media queries for containers with width. This helps apply responsiveness and within those, modify the container class accordingly to render the grid system correctly.

Check this out:  Versions of CSS

Frequently Asked Questions

What is Bootstrap?

Bootstrap is a free & open-source CSS framework that aims to be a mobile-first front-end web development framework. It contains CSS & JavaScript-based interface components and design templates like forms, buttons, navbar, and many more.

What is meant by CSS?

Cascading Style Sheets is the language that is used for describing the presentation of Web pages. It includes colors, layout, and fonts, thus making our web pages presentable to the users.

What is the use of CSS?

CSS is used for styling web content. It is time-saving, easily editable, has a wider range of attributes, etc. 

What is the difference between Bootstrap and CSS?

CSS is used for styling the webpage while bootstrap is a front-end framework used for creating websites.

What are the disadvantages of using Bootstrap?

Bootstrap is very time consuming as it takes much effort in rewriting a lot of styles while designing the websites. Also, the design deviates from the traditional method used in Bootstrap. 

Conclusion

This article teaches us how to use Bootstrap CSS Overview in our projects and make our websites faster by the magic of templating and open source. You can refer to other such articles using the below links:

  1. Bootstrap Transition Plugin
  2. Bootstrap- Scrollspy Plugin
  3. Bootstrap -Tooltip Plugin
  4. Bootstrap Accordion
     

Please refer to our guided paths on Coding Ninjas Studio to learn more about DSACompetitive ProgrammingJava Programming, and System Design, etc. Have a look at the interview experiences and interview bundle for placement preparations. And also, enroll in our courses and refer to the mock test and problems available.

All the best for your future endeavors, and Keep Coding!!

Live masterclass