How do you change the left margin of an element in CSS?
a) Padding-left b) Margin-left c) Margin-right d) Padding-right
Correct Answer: b) Margin-left
Explanation: The margin-left property sets the space between the element's left border and surrounding elements.
Question 42
Can you use negative values when using the padding property?
a) Yes b) No
Correct Answer: b) No
Explanation: Padding cannot have negative values; it only accepts positive values to create space inside an element’s border.
Question 43
How do you make a list that lists its items with squares in CSS?
a) List-style: square; b) List-style-type: square; c) List-decoration: square; d) List-type: square;
Correct Answer: b) List-style-type: square;
Explanation: The list-style-type property defines the type of marker for list items, such as squares.
Question 44
How do you select an element with the ID ‘demo’ in CSS?
a) .demo b) #demo c) demo d) [demo]
Correct Answer: b) #demo
Explanation: IDs are selected using a hash (#) followed by the ID name.
Question 45
How do you select elements with class name ‘test’ in CSS?
a) .test b) #test c) test d) [test]
Correct Answer: a) .test
Explanation: Classes are selected using a period (.) followed by the class name.
Question 46
How do you select all <p> elements inside a <div> element in CSS?
a) div, p b) div p c) div > p d) div + p
Correct Answer: b) div p
Explanation: The space between div and p selects all <p> elements that are descendants of <div> elements.
Question 47
How do you group selectors in CSS?
a) Separate each selector with a space b) Separate each selector with a comma c) Separate each selector with a semicolon d) Group selectors cannot be used
Correct Answer: b) Separate each selector with a comma
Explanation: Grouping selectors allows you to apply the same style to multiple elements by separating them with commas.
Question 48
What is the default value of the position property in CSS?
a) Absolute b) Relative c) Static d) Fixed
Correct Answer: c) Static
Explanation: The default value for the position property is static, which places elements in the normal document flow.
Question 49
Which of the following is the correct HTML for adding a yellow background color?
a) <body style=”background-color:yellow;”> b) <body bg-color=”yellow”> c) <body bgcolor=”yellow”> d) <body background=”yellow”>
Correct Answer: a) <body style="background-color:yellow;">
Explanation: The background-color property within the style attribute is the correct way to set the background color in HTML.
Question 50
Which HTML element is used to define important text?
a) <strong> b) <em> c) <mark> d) <b>
Correct Answer: a) <strong>
Explanation: The <strong> tag indicates text that is of strong importance and typically renders in bold.