React · Junior · Question 31 of 75
How do you set an inline style in JSX?
- 1
style="color: red; font-size: 14px" - ✓Correct answer:
style={{ color: "red", fontSize: 14 }} - 3
style={["color: red", "font-size: 14px"]}
Explanation
style takes an object with camelCase properties. The outer braces embed an expression, the inner ones are an object literal. For most properties, numeric values are interpreted as pixels (fontSize: 14 → 14px).