Module 2 (CSS)
Module 2 (CSS)
INPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Document</title>
<style>
h1{
color: red;
}
#p{
background-color: aqua;
color: red;
font-size: 30px;
font-weight: bolder;
}
#border {
height: 150px;
width: 150px;
background-color: aqua;
margin: 50px;
border-radius: 50%;
}
</style>
</head>
<body>
<h1>Hello World</h1>
<div id="p">This is a division tag</div>
<div id="border"></div>
</body>
</html>
OUTPUT:
Example of opacity:
INPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Document</title>
<style>
div{
display: flex;
}
.border{
height: 150px;
width: 150px;
background-color: red;
margin: 50px;
display: flex;
opacity: 1;
}
.border1{
height: 150px;
width: 150px;
background-color: red;
margin: 50px;
display: flex;
opacity: 0.5;
}
.border2{
height: 150px;
width: 150px;
background-color: red;
margin: 50px;
display: flex;
opacity: 0.1;
}
</style>
</head>
<body>
<div>
<div class="border"></div>
<div class="border1"></div>
<div class="border2"></div>
</div>
</body>
</html>
Output:
Input:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Document</title>
<style>
.border{
height: 150px;
width: 150px;
background-color: red;
margin: 50px;
}
</style>
</head>
<body>
<div>
<div class="border"></div>
</div>
</body>
</html>
Output:
INPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Document</title>
<style>
div{
display: flex;
margin: 50px;
}
#img1{
height: 500px;
width: 300px;
background-image: url(image/1_Transforming_Business.jpg);
background-size: 200px;
}
#img2{
height: 500px;
width: 300px;
background-image: url(image/1_Transforming_Business.jpg);
background-size: contain;
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div>
<div id="img1"></div>
<div id="img2"></div>
</div>
</body>
</html>
OUTPUT:
Output:
Q9: Which property controls the image scroll in the background?
Ans: The property that controls the image scroll in back-ground called as
Background-attachment.
It determines whether a background image scroll with content or remains fixed in
place as the user scroll through the page.
Input:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Document</title>
<style>
div {
display: flex;
margin: 50px;
}
#img1{
height: 200px;
width: 300px;
background-image: url(image/1_Transforming_Business.jpg);
background-size: cover;
background-attachment: local;
}
</style>
</head>
<body>
<div>
<div id="img1"></div>
<div id="img2"></div>
</div>
</body>
</html>
Output:
}
</style>
</head>
<body>
<h1 id="one1">Hello World</h1>
<center>
<h1 id="one2">This is a heading</h1>
</center>
</body>
</html>
Output:
(1) Inline CSS: Inline CSS placing CSS directly within an html element’s ‘style’
attributes.
Example:
<p style=” color: red; font-size: 20px;”>This is a paragraph</p>
(2) Internal CSS: Internal CSS defined within the ‘<style> tags in the head section of
an html document.
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Document</title>
<style>
#one1{
background-color: red;
text-align: center;
}
#one3{
background-color: aqua;
}
</style>
</head>
<body>
<h1 id="one1">Hello World</h1>
<h1 id="one2">This is a heading</h1>
</body>
</html>
(3) External CSS: External CSS defining with the separate CSS file. And linking it to
an html document using the ‘<link>’ tag.
Example:
Html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1 id="one1">Hello World</h1>
<h1 id="one2">This is a heading</h1>
</body>
</html>
CSS:
#one1{
background-color: red;
text-align: center;
}
#one3{
background-color: aqua;
}
OUTPUT:
}
</style>
</head>
<body>
<h1 id="one1">Hello World</h1>
<h1 id="one2">This is a heading</h1>
</body>
</html>
Q15: What are the external style sheets?
Ans: External CSS defining with the separate CSS file. And linking it to an html document
using the ‘<link>’ tag.
Example:
Html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1 id="one1">Hello World</h1>
<h1 id="one2">This is a heading</h1>
</body>
</html>
CSS:
#one1{
background-color: red;
text-align: center;
}
#one3{
background-color: aqua;
OUTPUT:
.one {
Height: 200px;
Background-color: red;
}
a{
text-decoration: none;
}
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Document</title>
<style>
/* this is a box */
.one {
height: 300px;
width: 350px;
border: 2px solid gray;
background-color: aqua;
margin-left: 50px;
}
/* this is a main div of all box */
#m1 {
margin-top: 50px;
display: flex;
justify-content: center;
}
/* this is a grey thumbnail */
.two {
height: 170px;
background-color: rgb(93, 93, 93);
font-size: 25px;
color: white;
box-sizing: border-box;
text-align: center;
padding-top: 70px;
.three {
height: 130px;
background-color: white;
text-align: justify;
padding-left: 20px;
padding-right: 20px;
padding-top: 10px;
box-sizing: border-box;
}
/* this is a button */
button {
margin-top: 20px;
width: 60px;
}
</style>
</head>
<body>
<div id="m1">
<!-- box 1 -->
<div class="one">
<div class="two">Thumbnail</div>
<div class="three">Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Fugiat quis vel enim possimus
ea laudantium dolorem nulla quibusdam sunt.
<button>View</button><button>Edit</button> </div>
</div>
<!-- box 2 -->
<div class="one">
<div class="two">Thumbnail</div>
<div class="three">Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Fugiat quis vel enim possimus
ea laudantium dolorem nulla quibusdam sunt.
<button>View</button><button>Edit</button></div>
</div>
<!-- box 3 -->
<div class="one">
<div class="two">Thumbnail</div>
<div class="three">Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Fugiat quis vel enim possimus
ea laudantium dolorem nulla quibusdam sunt.
<button>View</button><button>Edit</button></div>
</div>
</div>
<div id="m1">
<!-- box 4 -->
<div class="one">
<div class="two">Thumbnail</div>
<div class="three">Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Fugiat quis vel enim possimus
ea laudantium dolorem nulla quibusdam sunt.
<button>View</button><button>Edit</button></div>
</div>
<!-- box 5 -->
<div class="one">
<div class="two">Thumbnail</div>
<div class="three">Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Fugiat quis vel enim possimus
ea laudantium dolorem nulla quibusdam sunt.
<button>View</button><button>Edit</button></div>
</div>
<!-- box 6 -->
<div class="one">
<div class="two">Thumbnail</div>
<div class="three">Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Fugiat quis vel enim possimus
ea laudantium dolorem nulla quibusdam sunt.
<button>View</button><button>Edit</button></div>
</div>
</div>
</body>
</html>
OUTPUT: