0
0
Reactframework~5 mins

JSX vs HTML differences in React - Quick Revision & Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What is JSX in React?
JSX is a syntax extension for JavaScript that looks like HTML. It lets you write UI components in a way that feels like writing HTML but with the power of JavaScript.
Click to reveal answer
beginner
Why do we use className instead of class in JSX?
In JSX, class is a reserved word in JavaScript, so React uses className to assign CSS classes to elements.
Click to reveal answer
intermediate
How do you write inline styles in JSX compared to HTML?
In JSX, inline styles are written as an object with camelCase property names, for example: {'{ color: "red", fontSize: "12px" }'}, unlike HTML which uses a string.
Click to reveal answer
intermediate
What is the difference in how attributes like for are handled in JSX?
JSX uses htmlFor instead of for because for is a reserved word in JavaScript. This is used mainly with <label> elements.
Click to reveal answer
beginner
Can JSX elements have multiple root elements like HTML?
No, JSX requires a single root element. If you want multiple elements, you must wrap them in a parent element or use React fragments.
Click to reveal answer
Which attribute is used in JSX to add CSS classes?
AcssClass
Bclass
CclassName
DstyleClass
How do you write inline styles in JSX?
AAs an object with camelCase keys
BAs a string like in HTML
CUsing CSS files only
DUsing a style tag inside JSX
What must JSX elements have that HTML elements do not require?
AMultiple root elements
BNo attributes
COnly self-closing tags
DA single root element
Which attribute replaces 'for' in JSX when labeling form elements?
AforLabel
BhtmlFor
ClabelFor
DformFor
Can you use regular HTML comments inside JSX?
ANo, use JavaScript comments inside braces
BNo comments allowed
CYes, but only at the top
DYes, <!-- comment --> works
Explain the main differences between JSX and HTML attributes.
Think about reserved words in JavaScript and how JSX adapts HTML.
You got /4 concepts.
    Describe how JSX handles multiple elements compared to HTML.
    Consider how JSX compiles to JavaScript function calls.
    You got /3 concepts.