1. Which of the following is the correct way to select an element with id “header” in CSS?
(A) header
(B) #header
(C) header
(D) *header
2. How do you write a comment in CSS?
” onclick=”checkAnswer(‘q2′,’/* This is a comment */’)” /> (A) <!– This is a comment –>
(B) // This is a comment
(C) /* This is a comment */
(D) ** This is a comment **
3. Which CSS property is used to change the text color of an element?
(A) font-color
(B) color
(C) text-color
(D) foreground-color
4. How can you add a background image to a webpage using CSS?
(A) background-image: url(“image.jpg”);
(B) bg-image: “image.jpg”;
(C) background: “image.jpg”;
(D) image-background: url(“image.jpg”);
5. Which CSS property is used to set the border width of an element?
(A) border-size
(B) border-width
(C) border-style
(D) border-height
6. How can you select all <p> elements inside a <div> element?
p” onclick=”checkAnswer(‘q6′,’div p’)” /> (A) div > p
(B) div p
(C) div.p
(D) div p
7. Which of the following is an example of an invalid CSS statement?
(A) color: blue;
(B) font-size 16px;
(C) margin: 10px;
(D) padding: 5px;
8. How do you set the top margin of an element to 50 pixels?
(A) margin-top: 50px;
(B) margin: top 50px;
(C) top-margin: 50px;
(D) margin-top = 50px;
9. Which property is used to add space inside an element, between the content and the border?
(A) spacing
(B) margin
(C) padding
(D) border-spacing
10. Which of the following is NOT a valid CSS color format?
(A) #FF0000
(B) rgb(255,0,0)
(C) hsl(0,100%,50%)
(D) color(red)
11. Which selector is used to select all elements on a page?
(A) *
(B) all
(C) #all
(D) all
12. How do you apply a CSS rule to all elements of class “menu”?
(A) #menu { }
(B) menu { }
(C) menu { }
(D) *menu { }
13. Which CSS property is used to change the font of text?
(A) text-font
(B) font-style
(C) font-family
(D) text-style
14. How do you make a list not display bullets?
(A) list-type: none;
(B) list-style-type: none;
(C) bullet: none;
(D) list: none;
15. Which property controls the transparency of an element?
(A) opacity
(B) transparency
(C) filter
(D) visibility
16. Which of the following is the correct way to write multiple CSS rules for a single element?
(A) { color: red, font-size: 16px; }
(B) { color: red; font-size: 16px; }
(C) { color = red; font-size = 16px; }
(D) { color: red font-size: 16px; }
17. How do you select an element with the class “active” that is inside a <nav> element?
(A) nav.active
(B) nav .active
(C) nav .active
(D) #nav .active
18. Which property is used to set the background color of an element?
(A) background-color
(B) bg-color
(C) color
(D) background
19. Which of the following is the correct way to include an external CSS file in HTML?
” onclick=”checkAnswer(‘q19′,’‘)” /> (A) <link rel=”stylesheet” href=”style.css”>
” onclick=”checkAnswer(‘q19′,’‘)” /> (B) <style src=”style.css”>
” onclick=”checkAnswer(‘q19′,’‘)” /> (C) <script src=”style.css”>
” onclick=”checkAnswer(‘q19′,’‘)” /> (D) <css src=”style.css”>
20. Which property is used to add space between the element border and its content?
(A) margin
(B) padding
(C) spacing
(D) border-spacing
21. Which property is used to set the style of a border (e.g., solid, dashed, dotted)?
(A) border-type
(B) border-style
(C) border-format
(D) border-line
22. How do you set all four borders of an element to 5 pixels solid black in a single line?
(A) border: 5px solid black;
(B) border-width: 5px; border-color: black; border-style: solid;
(C) border: solid black 5px;
(D) border: 5 solid black;
23. Which property is used to set the horizontal space outside an element?
(A) padding-left
(B) margin-left
(C) border-left
(D) spacing-left
24. Which property is used to set the vertical spacing inside an element?
(A) padding-top
(B) margin-top
(C) line-height
(D) spacing-top
25. Which of the following is a valid CSS color name?
(A) bluish
(B) lightgreen
(C) brightred
(D) darkyellow
26. How can you hide an element visually but keep it accessible to screen readers?
(A) display: none;
(B) visibility: hidden;
(C) opacity: 0;
(D) position: absolute; left: -9999px;
27. Which property is used to set a background image that does not repeat?
(A) background-repeat: no-repeat;
(B) background-image: single;
(C) background-norepeat: true;
(D) background: no-repeat;
28. Which CSS statement contains a syntax error?
(A) color: blue;
(B) font-size: 14px;
(C) margin 10px;
(D) padding: 5px;
29. How do you set the background color with transparency?
(A) background-color: rgba(255, 0, 0, 0.5);
(B) background-color: rgb(255, 0, 0, 0.5);
(C) background-color: transparent-red;
(D) background-opacity: 0.5;
30. Which CSS property is shorthand for setting all four margins at once?
(A) margin-all
(B) margin
(C) margins
(D) margin-quad
31. Which of the following selectors will select all <a> elements inside a <li>?
(A) li a
a” onclick=”checkAnswer(‘q31′,’li a’)” /> (B) li > a
(C) li a
(D) li.a
32. How do you make text bold using CSS?
(A) font-weight: bold;
(B) text-style: bold;
(C) font-style: bold;
(D) text-weight: bold;
33. Which property controls the space between the border and the element content?
(A) margin
(B) padding
(C) spacing
(D) border-spacing
34. How can you select all <p> elements that are direct children of a <div>?
p” onclick=”checkAnswer(‘q34′,’div > p’)” /> (A) div > p
p’)” /> (B) div p
p’)” /> (C) div p
p’)” /> (D) div + p
35. Which is the correct syntax to include internal CSS in HTML?
h1 { color: red; }
” onclick=”checkAnswer(‘q35′,’
‘)” /> (A) <style> h1 { color: red; } </style>
h1 { color: red; } ” onclick=”checkAnswer(‘q35′,’
‘)” /> (B) <css> h1 { color: red; } </css>
h1 { color: red; } ” onclick=”checkAnswer(‘q35′,’
‘)” /> (C) <script> h1 { color: red; } </script>
h1 { color: red; } ” onclick=”checkAnswer(‘q35′,’
‘)” /> (D) <link> h1 { color: red; } </link>
36. How do you write a single-line comment in CSS?
(A) // This is a comment
(B) /* This is a comment */
” onclick=”checkAnswer(‘q36′,’/* This is a comment */’)” /> (C) <!– This is a comment –>
(D) ** This is a comment **
37. Which property is used to change the space between letters in text?
(A) letter-spacing
(B) word-spacing
(C) text-spacing
(D) character-spacing
38. Which of the following is NOT a valid way to specify a color in CSS?
(A) #00FF00
(B) rgb(0,255,0)
(C) hsl(120,100%,50%)
(D) color(0,255,0)
39. How do you create a border that is 2 pixels thick, dashed, and blue?
(A) border: 2px dashed blue;
(B) border-style: 2px dashed blue;
(C) border: dashed 2px blue;
(D) border-width: 2px; border-color: blue; border-style: dashed;
40. Which property sets the background image position?
(A) background-position
(B) background-align
(C) bg-position
(D) background-location
41. Which of these CSS statements contains an error?
(A) color: red;
(B) margin-top 10px;
(C) padding: 5px;
(D) border-style: solid;
42. Which shorthand property can set width, style, and color of a border in one line?
(A) border
(B) border-style
(C) border-width
(D) border-color
43. How do you select an element with both classes “menu” and “active”?
(A) menu.active
(B) menu .active
(C) menu.active
(D) #menu.active
44. Which property is used to repeat a background image vertically?
(A) background-repeat: repeat-y;
(B) background-repeat: repeat-x;
(C) background-vertical: repeat;
(D) background-repeat: repeat;
45. Which property changes the height of an element’s border?
(A) border-height
(B) border-width
(C) border-size
(D) border-style
46. How do you apply CSS to all <h1> and <h2> elements at once?
(A) h1, h2 { }
(B) h1 + h2 { }
(C) h1 h2 { }
(D) h1, .h2 { }
1. Which property adds a shadow to the element's box?
(A) border-shadow
(B) text-shadow
(C) shadow-box
(D) box-shadow
2. How do you select the first paragraph in a <div>?
(A) div:first p
(B) div p:first
(C) div p:first-child
(D) div p:first-of-type
3. Which of the following is the correct way to center text?
(A) align-text: center;
(B) text-align: center;
(C) text-center: true;
(D) center-text: yes;
4. Which property is used to control the vertical spacing between lines of text?
(A) vertical-spacing
(B) text-height
(C) spacing
(D) line-height