One & Two Marks
One & Two Marks
Ans B) ul li:first-child
18.A clip-path can use shapes like circle, ellipse and __________ to define
the visible area of an element. Ans polygon
19.The CSS property letter-spacing can be increased by setting its value to
__________. Ans 2px
20.Identify the error in the following code and suggest a correction:
</div>
Solution: Replace display: center; with display: flex; and add justify-content
and align-items for centering
.box {
width: 100px;
height: 100px;
background-color: red;
border-radius: 50px;
display: flex;
justify-content: center;
align-items: center;
}
3. Develop a CSS rule to display a <div>’s content in three columns with a
20px gap between columns.
Answer:
<html>
<head>
<title>Three Column Layout</title>
<style>
.three-column-layout {
column-count: 3;
column-gap: 20px;
}
</style>
</head>
<body>
<div class="three-column-layout">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Vivamus lacinia odio vitae vestibulum vestibulum.</p>
<p>Cras venenatis euismod malesuada.</p>
</div>
</body>
</html>
4. Create a program to illustrate the concept of CSS inheritance by styling a
parent <div> element with a font color of green, ensuring all child elements
automatically inherit this style.
Answer:
< html>
<head>
<title>CSS Inheritance Example</title>
</head>
<body>
<div style="color: green;">
<h1>This is a heading</h1>
<p>This is a paragraph within the parent <div>.</p>
<span>This is a span inside the parent <div>.</span>
</div>
</body>
</html>
5. Apply inline CSS to style a paragraph with a font size of 16px, font color of
blue, bold text and a background color of light gray. Provide the code snippet
to showcase this.
Answer:
<html>
<head>
<title>Inline CSS Example</title>
</head>
<body>
<p style="font-size: 16px; color: blue; font-weight: bold; background-color:
lightgray;">
This is a styled paragraph with inline CSS.
</p>
</body>
</html>
6. Illustrate how CSS transitions work and provide an example where the
background color of a button changes smoothly when hovered over.
Answer:
<html>
<head>
<style>
button {
background-color: blue;
color: white;
padding: 10px 20px;
border: none;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: green;
}
</style>
</head>
<body>
<button>Hover Me!</button>
</body>
</html>