When styling React components, you can use inline CSS or external CSS files. Both have their pros and cons.
šÆ Inline CSS:
⢠Defined directly inside the JSX as an object
⢠Styles are scoped to that component
⢠Quick for small components
<div style={{ color: "blue", fontSize: "20px" }}>Hello</div>
šÆ External CSS:
⢠Defined in .css files
⢠Easier for large projects
⢠Keeps code clean & reusable
.text {
color: blue;
font-size: 20px;
}
<div className="text">Hello</div>
š Which to use?
⢠Small, dynamic styles ā Inline CSS
⢠Big apps & reusable styles ā External CSS
Top comments (0)