Course contentsShow
← React
Lesson 1897 of 2,39644. Styling ApproachesFree lesson

What You Can't Do with Inline Styles

Missing CSS features in inline styles: pseudo-classes, pseudo-elements, media queries, keyframe animations, and CSS variables.

What You Can't Do with Inline Styles

You'll learn: Why inline styles hit a wall when you need advanced CSS features like hover effects, media queries, or animations.

The Limitations of JavaScript Objects

Inline styles in React use JavaScript objects, which means you're limited to CSS properties and values. All the dynamic, interactive, and responsive features of CSS that rely on special syntax simply don't translate into object notation.

Think of it like trying to cook a full meal using only a microwave. Sure, you can heat things up (apply basic styles), but you can't grill, sauté, or bake (use advanced CSS features).

What's Missing?

Pseudo-classes like :hover, :focus, or :active don't work. You can't write style={{ ':hover': { color: 'red' } }} — JavaScript objects don't understand CSS selectors.

Pseudo-elements like ::before and ::after are impossible. These require selector syntax that doesn't exist in the style prop.

Media queries can't be defined inline. You can't write style={{ '@media (max-width: 768px)': { fontSize: '14px' } }} because the style prop only accepts property-value pairs, not at-rules.

Keyframe animations require @keyframes definitions that live outside any single element's styles. Inline styles have no mechanism for this.

CSS variables (custom properties) technically work for reading values, but you can't define them inline in a way that cascades to children effectively.

The Workaround Landscape

You'll need to combine inline styles with CSS classes, use JavaScript event handlers for pseudo-class behavior, or reach for CSS-in-JS libraries that generate actual stylesheets behind the scenes.

Key Takeaway: Inline styles are perfect for dynamic property values but can't handle CSS's selector-based, responsive, or animation features — you'll need real CSS or CSS-in-JS for those.