Open Book Test 1 Js
Open Book Test 1 Js
1. How can you center an element horizontally within its parent using CSS?
a) Using the "text-align" property
b) Using the "align" property
c) Using the "margin-center" property
d) Using the "position" property
7. Explain the concept of the CSS box model and its components.
a) The CSS box model defines the positioning of elements using the "position" property.
b) The box model consists of margin, padding, border, and content properties that
determine the space around an element.
c) The box model refers to the arrangement of boxes within a grid layout.
d) The box model is used to create responsive designs using media queries.
9. Analyze the benefits and drawbacks of using web fonts in comparison to standard fonts.
a) Web fonts offer more design flexibility but may increase page load time. Standard fonts
are faster to load but have limited customization options.
b) Web fonts are limited in variety, while standard fonts provide a wide range of choices
for typography.
c) Web fonts are only supported in modern browsers, making them less suitable for cross-
browser compatibility.
d) Standard fonts are more suitable for mobile devices, while web fonts are preferred for
desktop applications.
10. Evaluate the role of animations and transitions in enhancing user experience on websites.
a) Animations and transitions have no impact on user experience and should be avoided to
ensure fast loading times.
b) Animations and transitions can make a website more engaging by adding visual interest
and guiding user interactions.
c) Animations are only suitable for entertainment websites, while transitions are essential
for business websites.
d) Animations and transitions are only supported in older browsers, making them obsolete
for modern web development.
Fill in the blank to create a CSS rule to change the text color to red:
p{
color: ______;
}
<div class="container">
<p>This is a paragraph.</p>
</div>
13. What does the `position: absolute;` CSS property value do?
.element {
position: ______;
}
14. Add CSS to the following code snippet to give the paragraph a green background color and
10px padding:
<style>
p{
background-color: ______;
padding: ______;
}
</style>
<p>This is a paragraph.</p>
15. Complete the media query to apply styles when the viewport width is less than 600 pixels:
16. Analyze the following code snippet and identify its purpose:
17. Evaluate the differences between the `transition` and `animation` properties in CSS and
explain when each is typically used.
19. Create an HTML <input> element of type "email" with a placeholder "Enter your email".
<input type="______" placeholder="Enter your email">
20. Explain how the HTML5 <nav> element is typically used in a web page structure.
<______>
<!-- Navigation links here -->
</______>
21. What position value should be used to position the element relative to its normal position
while still reserving space?
`
22. What value should be inserted in the blank to ensure that the content width and height are
included in the total dimensions of the box?
23. Answer: box-sizing: border-box;
What rule should replace the blank to define a keyframe animation that gradually fades in an
element?
Answer: fade-in
What condition should be inserted in the blank to apply the contained styles only when the
viewport width is 600px or less?
26. Fill in the missing part of the code to create a CSS animation that moves an element from left
to right:
@keyframes slide {
from {
transform: translateX(____%);
}
to {
transform: translateX(____%);
}
}
27. Complete the code to create a gradient background that goes from blue to white:
.gradient-bg {
background-image: ____-gradient(blue, white);
}
28. Examine the following HTML code. What is the purpose of the `<meta>` tag with the
`viewport` attribute?
```html
<meta name="viewport" content="width=device-width, initial-scale=1.0">
```
29. Apply an inline CSS style to make the following paragraph text green:
30. Apply a CSS rule to center-align the text within a `<div>` element with the class name
"centered-content":
31. Apply CSS to create a red button with white text color. Use the class "red-button" for the
button element.
32. Apply a CSS animation to make an image rotate continuously. Use the class "rotate-image" for
the image element.
33. Apply a box shadow to an image with the class `.image-box`. The shadow should have a
horizontal offset of 5 pixels, a vertical offset of 5 pixels, a blur radius of 10 pixels, and a color
of rgba(0, 0, 0, 0.3).
.image-box {
width: 200px;
height: 150px;
background-image: url('image.jpg');
}
34. Apply a Google Fonts web font named "Roboto" to the following CSS rule for a paragraph:
```css
p{
/* Apply the web font here */
}
35. Link the "Open Sans" web font from Google Fonts in the HTML head section:
36. Write a CSS rule that uses the web font "Lato" and sets the font weight to bold for a class
named `.custom-heading`:
.custom-heading {
/* Apply the web font and font weight here */
}
37. Explain how the use of web fonts might impact page load time and suggest a way to optimize
font loading.
38. Compare using a system font stack with using a web font. Provide an example of a system font
stack.
39. Create a multi-column layout with 3 equal-width columns using the CSS `column-count`
property:
.multi-column-container {
/* Apply the multi-column layout here */
}
40. Implement a responsive multi-column layout with a gap of 20 pixels between columns, which
changes to a single column on screens narrower than 600px:
.responsive-columns {
/* Apply the responsive multi-column layout here */
}
41. Describe how the CSS `column-span` property works and provide an example of its usage.
42. Apply a specific width and a column gap of 15 pixels to a multi-column layout with class
`.custom-columns`:
.custom-columns {
/* Apply the width and column gap here */
}
43. Discuss the advantages of using a multi-column layout for text-heavy content like articles, and
illustrate with a code snippet.
44. Apply the `font-family` property to change the font of a paragraph to a web font named
"Open Sans".
Code Snippet:
45. Link the Google Fonts API to include the "Roboto" font in your HTML document.
Code Snippet:
```html
<!-- Link the Google Fonts API here -->
<link rel="stylesheet" href="styles.css">
46. Create a CSS rule to apply a web font named "Lato" with a font weight of 700 (bold) to all
headings (h1 to h6).
```css
/* Apply the font rule here */
h1, h2, h3, h4, h5, h6 {
font-size: 24px;
}
```
47. Implement a multi-column layout with three equal-width columns using the CSS `column-
count` property.
48. Create a multi-column layout with a gap of 20 pixels between columns using the CSS `column-
gap` property.
49. Design a responsive multi-column layout that switches to a single column on screens narrower
than 600 pixels using media queries.
```css
/* Design the responsive multi-column layout here */
.column-container {
column-count: 2;
column-gap: 20px;
}