xxxxxxxxxx
// In JSX, you can’t use the word class! You have to use className instead. This is because JSX gets translated into JavaScript, and class is a reserved word in JavaScript.
// When JSX is rendered, JSX className attributes are automatically rendered as class attributes.
// When rendered, this JSX expression...
const heading = <h1 className="large-heading">Codecademy</h1>;
// ...will be rendered as this HTML
<h1 class="large-heading">Codecademy</h1>
xxxxxxxxxx
Unlike regular HTML, in React, you need to use className
instead of class to define a class name for an element.
This is because class is a reserved keyword in JavaScript.