React · Junior · Question 4 of 75

How do you set a CSS class on an element in JSX?

Explanation

JSX is closer to JavaScript, and class is a reserved word, so attributes are named like DOM properties: className, htmlFor instead of for, tabIndex, onClick. data-* and aria-* attributes are written as in HTML.

Further reading

Problem with a question

React · Junior · question 4

Test yourself

Take the React · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz