If you are a web developer, then you must have come across the need to write css code for styling your website. Without CSS, the website will look dull and will not be able to retain visitors.
With the advancement of web technologies, many new and amazing features and design properties were added to CSS to let web developers create beautiful websites.
But consider the case where you want to develop a web app, which doesn’t require some very catchy or sophisticated CSS style but need some minimal styling so that the website look decent and usable. This is where Bootstrap comes into play.
Bootstrap is a CSS library which consists of some pre-built css designs for various components like button, link, text, card, etc. You can directly use the styling by defining the class property and the css will take effect. This is really helpful while building web applications quickly without the need to worry much about styling. Of course, you have the option to customise the bootstrap elements if you wish to. Let us discuss how to get started with bootstrap.
To use bootstrap in your web project, you can do any one of the following:
- Download bootstrap library on your machine and include the styling files wherever necessary.
You can choose any of the above mentioned ways. To choose, you can consider factors like space availability on your computer, internet connectivity, etc. Whichever way you choose, bootstrap will work the same way. In this post, I will show the second way of implementing bootstrap i.e. using a CDN.
Paste the code snippets given below in the head section of your webpage:
<link rel="stylesheet" href="https://email@example.com/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<script src="https://firstname.lastname@example.org/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V" crossorigin="anonymous"></script>
After you do this, you are good to go. You can now implement bootstrap styles in your webpage.
Here are some types of buttons you can implement.
<button type="button" class="btn btn-primary">Primary</button> <button type="button" class="btn btn-secondary">Secondary</button> <button type="button" class="btn btn-success">Success</button> <button type="button" class="btn btn-danger">Danger</button> <button type="button" class="btn btn-warning">Warning</button> <button type="button" class="btn btn-info">Info</button> <button type="button" class="btn btn-light">Light</button> <button type="button" class="btn btn-dark">Dark</button> <button type="button" class="btn btn-link">Link</button>
In this way, you can implement other components like containers, cards, text etc. as well Visit this link to find all the components. Remember, this website will provide all the necessary documentation required for implementing bootstrap.
How does it work?
In the example of buttons that I gave here, look at the class attribute. This class attribute renders the styles to the buttons, because bootstrap has defined certain styles for the particular class and when we implement it, the element in which it is implemented shows the effect.
Have you ever wondered how websites are made responsive, i.e. how the design of the website changes with changing screen size? The answer is using media queries and defining breakpoints. In easy language, consider it as some conditions regarding screen sizes, when a particular screen size is reached, the alignment of the components change to make the website adapt to the new screen size.
If you were to write these media queries, it will take a lot of time. Bootstrap automatically takes care of it using containers and its grid system. So, you just need to build your website using bootstrap components and bootstrap will take care of the responsiveness. You can visit this site to know more about the grid system of bootstrap.
Bootstrap provides an easy and quick solution for building beautiful and responsive websites. You can easily implement bootstrap to develop your websites. Also, you can use bootstrap components along with frontend frameworks like React.js. You just need to install bootstrap using your package manager (npm or yarn).
Hope you find this post helpful. Thanks for reading.