How to link bootstrap on your own project? Define the possible methods for linking the Bootstrap files on your project.

Asked 28-Jul-2021
Viewed 144 times

0

How to link bootstrap on your own project? Define the possible methods for linking the Bootstrap files on your project.


1 Answer


0

If we can use the bootstrap framework on our website, we must link the file in our project. We can link bootstrap in our Html file using the CDN file and simply downloaded the file (using a package manager). If we use the CDN files then doesn't need to download these file in our projects but if we use the package manager then we need to download the all file of bootstrap then link in Html page. 

if we use CDN in our projects then we do not need to download all CSS, JavaScript files, because all CDN files are store on the server. we link CDN in the project then on executing the HTML page browser automatically call the CDN server and execute them. but if use the file system in projects then first of all download the bootstrap file and link in our project. 

if we use the CDN file, then don't need to update your CDN file because automatically call the server and fetch classes but we use the file system, then we need to keep it updated from time to time.  

  1. CDN file
  2. Package manager

CDN file

add CSS

Copy-paste the stylesheet <link> into your <head> before all other stylesheets to load our CSS.

<link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous'>

JavaScript

 <script>s near the end of your pages, right before the closing </body> tag, to enable them. 

<script src='https://code.jquery.com/jquery-3.3.1.slim.min.js' integrity='sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo' crossorigin='anonymous'></script>

<script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js' integrity='sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1' crossorigin='anonymous'></script>
<script src='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js' integrity='sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM' crossorigin='anonymous'></script>


Package manager

add CSS

Copy-paste the stylesheet <link> into your <head> before all other stylesheets to load our CSS.

<link rel='stylesheet' href='.../bootstrap.min.css' integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous'>

JavaScript

 <script>s near the end of your pages, right before the closing </body> tag, to enable them.

<script src='.../jquery-3.3.1.slim.min.js' integrity='sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo' crossorigin='anonymous'></script>

<script src='.../popper.min.js' integrity='sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1' crossorigin='anonymous'></script>
<script src='.../bootstrap/4.3.1/js/bootstrap.min.js' integrity='sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM' crossorigin='anonymous'></script>

 Notes:    ... indicate the directory of linked files. 


Example  
<!doctype html>
<html lang='en'>
  <head>
    <!-- Required meta tags -->
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>
    <!-- Bootstrap CSS -->
    <link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous'>     <title>Hello, world!</title>   </head>   <body>     <div class='container mt-1'>         <h1 class='bg-primary rounded text-white text-center'>Hello, world!</h1>     </div>     <!-- Optional JavaScript -->     <!-- jQuery first, then Popper.js, then Bootstrap JS -->     <script src='https://code.jquery.com/jquery-3.3.1.slim.min.js' integrity='sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo' crossorigin='anonymous'></script>     <script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js' integrity='sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1' crossorigin='anonymous'></script>     <script src='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js' integrity='sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM' crossorigin='anonymous'></script>   </body> </html>
Output
How to link bootstrap on your own project? Define the possible methods for linking the Bootstrap files on your project.