CSS and Bootstrap
CSS and Bootstrap
CSS and Bootstrap
<!DOCTYPE html>
<html>
<head>
<style>
p {
color: red;
text-align: center;
}
</style>
</head>
<body>
<p>Geeksforgeeks</p>
<p>
</p>
</body>
</html>
Output:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width,
initial-scale=1">
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js">
</script>
<script src=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js">
</script>
</head>
<body>
<div class="container">
<ul>
<li class="text-muted">GeeksforGeeks</li>
<li class="text-primary">GeeksforGeeks</li>
<li class="text-success">GeeksforGeeks</li>
<li class="text-info">GeeksforGeeks</li>
<li class="text-danger">GeeksforGeeks</li>
<li class="text-secondary">GeeksforGeeks</li>
<li class="text-white">GeeksforGeeks</li>
<li class="text-dark">GeeksforGeeks</li>
</ul>
</div>
</body>
</html>
Output:
CSS represent the style and the Bootstrap is a free and open-source CSS
appearance of content like font, color, Framework that is used for developing
margin, padding, etc. responsive website.
CSS does not have a grid system. Bootstrap is based on-grid system.
CSS does not provide responsive pages In Bootstrap we can design a responsive
or website. website or webpages.
In CSS, we have to write code from In Bootstrap, we can add pre-defined class
scratch. into the code without writing code.
CSS and JavaScript both are used on Web pages with HTML but for different roles.
CSS is used to design the webpage for better layouts for the user, that the user can feel
comfortable with the Web page. JavaScript is used to create interaction between
webpages and the user.
CSS: CSS stands for Cascading Style Sheet, it is a style sheet language used to shape
the HTML elements that will be displayed in the browsers as a web-page. Without
using CSS, the website which has been created by using HTML will look dull.
Basically CSS gives the outer cover on any HTML elements. If you consider HTML
as a skeleton of the web-page then the CSS will be the skin of the skeleton. The
Internet media type (MIME type) of CSS is text/CSS.
CSS Features:
CSS is compatible with all the devices.
With the help of CSS, website maintenance is easy and faster.
CSS support consistent and spontaneous changes.
CSS makes the website faster and enhances search engine capabilities to crawl the
web pages.
It holds a special feature that is the ability to re-position.
JavaScript: It is a lightweight, cross-platform, and interpreted scripting language. It is
well-known for the development of web pages, many non-browser environments also
use it. JavaScript can be used for Client-side developments as well as Server-side
developments. JavaScript contains a standard library of objects, like Array, Date, and
Math, and a core set of language elements like operators, control structures, and
statements. JavaScript can be used as Client-Side as well as Server-Side.
JavaScript Features:
JavaScript was created in the first place for DOM manipulation. Earlier websites
were mostly static after JavaScript it was created dynamic Web sites.
Functions in JS are objects. They may have properties and methods just like
another object. They can be passed as arguments in other functions.
It can handle date and time.
Performs Form Validation although the forms are created using HTML.
No compiler needed.
Difference between CSS and JavaScript:
CSS Javascript
CSS directly defines in the <style> tag in The <script> tag should be used for
HTML. JavaScript code.
CSS can not approve shapes, can be JavaScript can approve shapes, can be
utilized to identify guest browsers, and utilized to identify guest browsers, and
can be utilized to recover and store data can be utilized to recover and store data
from visitors’ computers. from visitors’ computers.
Jquery It has jquery and all related Jquery is removed and switched
plugins. to vanilla JS with some working
BASIS OF BOOTSTRAP 4 BOOTSTRAP 5
plugins
Gutter We use .glutter with fontsize in px We use .g* with fontsize in rem
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
color: green;
text-align: center;
}
</style>
</head>
<body>
<h1>GeeksforGeeks</h1>
</body>
</html>
Output:
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
color: green;
text-align: center;
}
</style>
</head>
<body>
<h1>GeeksforGeeks</h1>
</body>
</html>
Output:
CSS id selector : The #id selector is used to set the style of the given id. The
id attribute is the unique identifier in an HTML document. The id selector is
used with a # character.
Syntax:
#id_name {
// CSS Property
}
Example: This example illustrates the use of the id selector for selecting the
HTML elements by their id & style them.
HTML
<!DOCTYPE html>
<html>
<head>
<!-- Style of id selector -->
<style>
#heading {
color: green;
text-align: center;
font-size: 40px;
font-weight: bold;
}
</style>
</head>
<body>
</body>
</html>
Output:
CSS class selector: The .class selector is used to select all elements which
belong to a particular class attribute. To select the elements with a particular
class, use (.) character with specifying the class name. The class name is
mostly used to set the CSS property to the given class.
Syntax:
.class_name {
// CSS Property
}
Example: This example illustrates the use of the class selector for selecting
the HTML elements by their class & style them.
HTML
<!DOCTYPE html>
<html>
<head>
<style>
.heading {
color: green;
text-align: center;
font-size: 40px;
font-weight: bold;
}
</style>
</head>
<body>
</body>
</html>
Output:
For applying the common CSS style properties to all the HTML Elements
then we can use the universal selector which is denoted by a star(*)
symbol.
CSS * Selector : The * selector in CSS is used to select all the elements in
an HTML document. It also selects all elements which are inside under
another element. It is also called the universal selector.
Syntax:
* {
// CSS property
}
Example: This example illustrates the use of the universal selector for
selecting all the HTML elements that contain the common CSS properties &
styles them.
HTML
<!DOCTYPE html>
<html>
<head>
<title>* Selector</title>
<style>
* {
color: green;
text-align: center;
}
</style>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h2>*(Universal) Selector</h2>
<div>
<p>GFG</p>
<p>Geeks</p>
</div>
</body>
</html>
Output:
Supported Browser:
Google Chrome 94.0
Microsoft Edge 94.0
IE 11.0
Firefox 93.0
Opera 80.0
Safari 15.0