Describe Types of CSS With Example and Their Properties
Describe Types of CSS With Example and Their Properties
1. id selector:
• The id selector is used to select a single element with a
unique id attribute.
• id attributes are assigned to an HTML element by using
the id attribute.
• An id attribute can only be used once on a page and it
should be unique across the entire document
• An id selector is represented by the "#" symbol followed by
the id name of an HTML element.
• For example:
<div id="myDiv">This is my div</div>
#myDiv {
color: blue;
}
2. class selector:
• The class selector is used to select multiple elements with
the same class attribute.
• class attributes are assigned to an HTML element by using
the class attribute.
• A class attribute can be used multiple times on a page
• A class selector is represented by a "." symbol followed by
the class name of an HTML element.
• For example:
<p class="myClass">This is a paragraph</p>
<p class="myClass">Another paragraph</p>
.myClass {
font-size: 20px;
}
The id selector and class selector are important for creating
specific styles for specific HTML elements, by using an id selector
we can target a unique element, and using a class selector we can
target multiple elements that share the same class. With these
selectors, you can achieve a great deal of control over the layout,
presentation and interactivity of your web page.
5. Steps of linking with bootstrap?
6. What are container classes?
In Bootstrap, the container class is used to create a container
for the main content of a web page. This container acts as a
wrapper for the content and is used to set the width and
alignment of the content. Here are some key points about the
container class in Bootstrap:
1. Width: The container class sets a fixed width for the container,
which is based on the size of the viewport (the width of the web
page). By default, the container has a width of 1170px on large
screens and 940px on medium screens and below.
2. Alignment: The container class is used to center the content
inside the container. The content is horizontally centered within
the container, which is useful for creating a consistent layout
across different screen sizes.
3. Responsiveness: The container class is designed to be
responsive, which means it will adapt to the size of the
viewport. On smaller screens, the container will take up a larger
percentage of the screen to ensure the content is still readable.
4. Multiple containers : You can use multiple container class to
create different sections of the layout and different styling,
depends on the design requirements.
5. Nesting: You can also nest multiple container classes inside
each other to create more complex layouts with different
widths and alignments.
What is Bootstrap?
• Bootstrap is a free front-end framework for faster and easier web
development
• Bootstrap includes HTML and CSS based design templates for
typography, forms, buttons, tables, navigation, modals, image
carousels and many other, as well as optional JavaScript plugins
• Bootstrap also gives you the ability to easily create responsive designs
• Easy to use: Anybody with just basic knowledge of HTML and CSS can
start using Bootstrap
• Responsive features: Bootstrap's responsive CSS adjusts to phones,
tablets, and desktops
• Mobile-first approach: In Bootstrap 3, mobile-first styles are part of
the core framework
• Browser compatibility: Bootstrap is compatible with all modern
browsers (Chrome, Firefox, Internet Explorer, Edge, Safari, and Opera)
Bootstrap uses HTML elements and CSS properties that require the HTML5
doctype.
Always include the HTML5 doctype at the beginning of the page, along with
the lang attribute and the correct character set:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
</html>
2. Bootstrap 3 is mobile-first
To ensure proper rendering and touch zooming, add the following <meta> tag
inside the <head> element:
The width=device-width part sets the width of the page to follow the screen-
width of the device (which will vary depending on the device).
The initial-scale=1 part sets the initial zoom level when the page is first
loaded by the browser.
3. Containers
.container
.container-fluid
Example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstra
p/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquer
y.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/boots
trap.min.js"></script>
</head>
<body>
<div class="container">
<h1>My First Bootstrap Page</h1>
<p>This is some text.</p>
</div>
</body>
</html>
The following example shows the code for a basic Bootstrap page (with a full
width container):
Example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstra
p/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquer
y.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/boots
trap.min.js"></script>
</head>
<body>
<div class="container-fluid">
<h1>My First Bootstrap Page</h1>
<p>This is some text.</p>
</div>
</body>
</html>