Understand how to apply CSS to your components. Learn the difference between global classes and component-specific inline objects.
StylingComponent.jsx
1/6
🎨
// Virtual Output
Styled with Class
> In React, we don't use the standard 'class' attribute. Instead, we use 'className' because 'class' is a reserved keyword in JavaScript.
The React Style Paradigm
In traditional HTML, we use the class attribute. However, React uses JSX, which is an extension of JavaScript. Since class is a reserved word in JS (for defining classes), React introduced className.
1. Inline Styles (The Object Way)
Inline styles in React are written as objects. This means property names are camelCased. For example, text-align becomes textAlign.