Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JSX className

// 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>
 
PREVIOUS NEXT
Tagged: #JSX #className
ADD COMMENT
Topic
Name
6+8 =