Which is the correct CSS syntax?

  1. body {color: black}

  2. {body;color:black}

  3. {body:color=black(body}

  4. body:color=black


Correct Option: A

AI Explanation

To answer this question, you need to understand the correct syntax for writing CSS rules.

Option A) body {color: black} - This option is correct because it follows the correct CSS syntax. In CSS, selectors (such as "body") are followed by a set of curly braces {}. Inside the curly braces, you define the properties and values (such as "color: black") for the selected element.

Option B) {body;color:black} - This option is incorrect because it does not include a valid selector before the curly braces {}. The selector is missing, so the CSS rule is not properly defined.

Option C) {body:color=black(body} - This option is incorrect because it includes invalid characters and incorrect syntax. CSS properties and values are separated by a colon (:), not an equal sign (=). Additionally, the closing parenthesis is placed incorrectly.

Option D) body:color=black - This option is incorrect because it does not use the correct syntax for defining CSS rules. The selector and the properties/values are not enclosed within curly braces {}.

The correct answer is Option A) body {color: black}. This option is correct because it follows the correct CSS syntax by including a selector (body), followed by a set of curly braces {}, and defining the property (color) and value (black) inside the curly braces.

Find more quizzes: