4

Styling in React

For generations, mankind (and probably really smart dolphins) has styled HTML content using CSS. Things were good. CSS had good separation between content and presentation. The selector syntax offered a lot of flexibility in choosing which elements to style and which ones to skip. We couldn’t even find many reasons to hate the whole cascading thing CSS is all about.

Well, don’t tell React that. React doesn’t actively hate CSS, but it has a different view when it comes to styling content. As you’ve seen, one of React’s core ideas is to make an app’s visual pieces self-contained and reusable. That’s why the HTML elements and the JavaScript that impacts them are in the same bucket, called a component. You got a taste of that ...

Get Learning React: A Hands-On Guide to Building Web Applications Using React and Redux, Second edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.