Multiple choice technology web technology

What is the correct HTML for adding a background color?

  1. <body background="yellow">

  2. <body style="background-color:yellow">

  3. <background>yellow</background>

  4. <bgcolor="yellow">

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The inline style attribute using CSS syntax (background-color) is the modern approach to adding background colors. Option A uses an obsolete attribute that's deprecated, and options C and D use non-existent HTML elements or invalid syntax.