Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
How do I use className to change appearance of html in reactjs?

I am currently learning ReactJS from a youtube tutorial and am trying to use className's to make the page look better. The tutorial I am following only added: className="card"> in the opening tag of a div element and it changed the page appearance though it does not seem to be working for me. Forgive me if this is a dumb question as I am not aware whether you have to import your own css files to change the appearance and the tutorial just did not show it. I would appreciate any responses. Thank you.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

The difference here is you are wanting to write JSX, and not standard HTML... it is VERY close, with some small but important differences.... here's an example of the same thing in HTML and JSX:

HTML: <div class="App">{/* some other code*/}</div>
JSX:<div className="App">{/* some other code */}</div>

The difference here is class/className. JSX uses camel case for an HTML element's attributes, as well as using different names for some as in this case. This is just the start of the differences but hopefully this leads you in the right direction!

about 4 years ago · Juan Pablo Isaza Report

0

You need to learn about CSS (cascading style sheets) (: HTML elements can be given classes like this

<html>
<head>
   <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="card">content</div>
</body>
</html>

And if you have a stylesheet (file ending in .css included in the <head> of your document

/* styles.css */ 
.card {
    background-color: red;
}

The styles described in the .card class section will be applied to your html element (in this case a red background)

You probably missed a step in your tutorial about including some pre-created style sheet.

CSS Basics

about 4 years ago · Juan Pablo Isaza Report

0

Answer updated after this comment :

The reason for that is that the css is being imported on a component above the one where he declared that code.

Example code :

/* App JS */
import './App.css';
import Title from './Title.jsx';

function App() {
  return (
    <div className="App">
      <Title />
    </div>
  );
}

export default App;
/* App.css */
.App{
  font-size: 14px;
}
.title {
  color: #e60000;
  font-size: 20px;
  text-decoration: underline;
}
/* Title.jsx */
export default function (){
    return <div className="title">Test</div>
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!