CSS - cascading style sheets, backgrounds, colours, fonts, borders, boxes, margins, padding, positioning, class and id selectors - Question Bank

1. What is the purpose of the CSS `!important` rule?
A) To make a style less important.
B) To override other CSS rules, making the rule with `!important` take precedence.
C) To define a new CSS property.
D) To group multiple CSS properties.
2. Which CSS property is used to control the overflow of content that exceeds the element's box?
A) overflow
B) content-overflow
C) box-overflow
D) scroll
3. What is the CSS shorthand property for setting all four margins (top, right, bottom, left) in order?
A) margin
B) padding
C) border
D) spacing
4. Which CSS property allows an element to occupy space but not be displayed?
A) visibility: hidden;
B) display: none;
C) opacity: 0;
D) hidden: true;
5. What does the CSS property 'text-decoration: none;' do?
A) It adds an underline to the text.
B) It removes any default text decorations like underlines.
C) It makes the text italic.
D) It makes the text uppercase.
6. Which CSS property is used to control the spacing between letters?
A) letter-spacing
B) word-spacing
C) font-spacing
D) character-spacing
7. What does the CSS selector `div > p` match?
A) All `p` elements inside any `div` element.
B) All `p` elements that are direct children of a `div` element.
C) All `p` elements immediately following a `div` element.
D) All `p` elements that share the same parent as a `div` element.
8. What is the CSS property for setting the background position?
A) background-position
B) bg-position
C) position-background
D) background
9. Which CSS property is used to set the style of the outline around an element?
A) outline-style
B) outline-type
C) style-outline
D) outline
10. What does the CSS pseudo-class ':hover' apply to?
A) An element when it is first loaded.
B) An element when the user clicks on it.
C) An element when the user moves the mouse pointer over it.
D) An element when it is in an invalid state.
11. Which CSS property is used to set the color of the text's outline?
A) outline-color
B) border-color
C) text-outline
D) font-outline
12. What is the CSS property for setting the height of an element?
A) height
B) element-height
C) size-height
D) content-height
13. Which CSS property is used to set the width of an element?
A) width
B) element-width
C) size-width
D) content-width
14. What does the CSS property 'opacity: 0;' do?
A) It makes the element completely transparent.
B) It hides the element completely, but it still occupies space.
C) It removes the element from the document flow.
D) It makes the element invisible and removes it from layout.
15. What is the CSS property for setting the vertical positioning of absolutely positioned elements?
A) top
B) bottom
C) y-position
D) vertical
16. Which CSS property is used to set the vertical alignment of text within an element?
A) vertical-align
B) text-vertical-align
C) align-vertical
D) valign
17. What does the CSS property 'float: left;' do?
A) It aligns the element to the left of its container.
B) It removes the element from the normal document flow and positions it to the left.
C) It makes the element appear on the left side of the page, allowing text to wrap around it.
D) It aligns text to the left.
18. Which CSS property is used to create a text shadow?
A) text-shadow
B) shadow-text
C) text-box-shadow
D) font-shadow
19. What is the CSS property for setting the horizontal positioning of absolutely positioned elements?
A) left
B) right
C) x-position
D) horizontal
20. Which CSS property is used to set the background image of an element?
A) background-image
B) background
C) bg-image
D) image-background
21. What does the CSS 'border-radius' property do?
A) It rounds the corners of an element's border.
B) It adds a shadow to the border.
C) It creates a dashed border.
D) It sets the border width.
22. Which CSS property controls the spacing between lines of text?
A) line-height
B) text-height
C) spacing-line
D) line-spacing
23. What is the CSS selector that targets elements that are direct children of another element?
A) Descendant selector (space)
B) Child selector (>)
C) Adjacent sibling selector (+)
D) General sibling selector (~)
24. Which CSS property is used to control the visibility of an element?
A) display
B) visibility
C) opacity
D) hidden
25. What is the CSS property for setting the color of the background image?
A) background-color
B) background-image-color
C) color-background
D) bg-color
26. Which CSS property is used to set the font family (e.g., Arial, Times New Roman)?
A) font-family
B) font-face
C) font-name
D) family-font
27. What does `display: inline-block;` do in CSS?
A) It makes the element behave like a block element but flow with text.
B) It makes the element behave like an inline element but allows width and height.
C) It hides the element and its content.
D) It positions the element absolutely.
28. Which CSS property allows you to stack elements that overlap using the z-axis?
A) z-index
B) stack-index
C) order
D) depth
29. What is the default value of the CSS 'position' property?
A) absolute
B) relative
C) fixed
D) static
30. Which CSS property specifies the color of the border?
A) border-color
B) border-colour
C) color-border
D) border
31. What is the CSS property for setting the font style (e.g., italic)?
A) font-style
B) text-style
C) style-font
D) font-variant
32. Which CSS property is used to set the color of text?
A) background-color
B) font-color
C) color
D) text-color
33. What does `position: fixed;` in CSS do?
A) Positions the element relative to its normal position.
B) Positions the element relative to its nearest positioned ancestor.
C) Removes the element from the document flow and positions it relative to the viewport.
D) Allows the element to overlap other elements.
34. Which CSS property is used to control the alignment of text within an element?
A) text-align
B) align-text
C) text-alignment
D) align
35. What is the CSS 'box model' composed of?
A) Content, Padding, Border, Margin
B) Content, Background, Border, Outline
C) Text, Image, Table, Div
D) Width, Height, Color, Font
36. Which CSS property is used to add space inside the border of an element?
A) margin
B) padding
C) border-spacing
D) inset
37. What is the correct CSS syntax for selecting an element with the ID 'main-content'?
A) .main-content
B) #main-content
C) id.main-content
D) element#main-content
38. Which CSS property is used to specify the width of an element's border?
A) border-width
B) border-thickness
C) border-size
D) width-border
39. What does the CSS property 'display: inline;' do?
A) The element takes up the full width available.
B) The element takes up only as much width as necessary.
C) The element flows like text, and other elements flow around it.
D) The element is hidden from view.
40. Which CSS property is used to control the repetition of a background image?
A) background-repeat
B) background-image-repeat
C) repeat-background
D) bg-repeat
41. What is the default font-family for most web browsers?
A) Arial
B) Times New Roman
C) Verdana
D) Inherited from user agent stylesheet
42. Which CSS property is used to set the style of the border around an element?
A) border-style
B) border-type
C) style-border
D) border-line
43. What is the correct CSS syntax for selecting all elements with the class 'example'?
A) #example
B) .example
C) element.example
D) class.example
44. What does the CSS property 'position: absolute;' do?
A) It positions the element normally in the document flow.
B) It allows the element to be positioned relative to its nearest positioned ancestor.
C) It removes the element from the document flow and positions it relative to the viewport.
D) It positions the element relative to its normal position, then offsets it.
45. Which CSS property is used to add space outside the border of an element?
A) padding
B) margin
C) border-spacing
D) outline
46. What is the purpose of the 'box-sizing' property in CSS?
A) It controls the space between elements.
B) It defines how the width and height properties are calculated.
C) It sets the background image repeat behavior.
D) It specifies the text alignment.
47. Which CSS property is used to make text bold?
A) font-weight: bold;
B) text-weight: bold;
C) font-style: bold;
D) font: bold;
48. What is the default value for the CSS 'display' property for a `<div>` element?
A) inline
B) inline-block
C) block
D) none
49. Which CSS property controls the text size of an element?
A) font-size
B) text-size
C) size
D) font-style
50. Which property is used to change the background color of an element in CSS?
A) color
B) background-color
C) background
D) bgcolor