How to use external css in bootstrap?
May 03, 2022Hi Friends 👋,
Welcome To aGuideHub! ❤️
Today, I am going to show you. How to use external css in bootstrap with code example.
With an external style sheet, you can change the look of an entire website by changing just one file!
Each HTML
page must include a reference to the external style sheet file inside the <link>
element, inside the head section.
External styles are defined within the <link>
element, inside the <head>
section of an HTML page:
<head>
<link rel="stylesheet" href="style.css">
</head>
An external style sheet can be written in any text editor, and must be saved with a .css
extension.
The external .css
file should not contain any HTML tags.
Here is how the "style.css"
file looks:
body {
background-color: rgb(59, 171, 208);
}
h1 {
color: rgb(4, 4, 83);
margin-left: 20px;
}
Example:
Let’s look at the following example to understand how it basically works:
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>This is my book </h1>
<p>That is you book.</p>
</body>
</html>
Check the output of the above code example.
All the best 👍