Facebook Pixel

Are HTML attributes the same in JSX?

Mostly, but they use camelCase. For example, tabindex becomes tabIndex. This is because JSX maps attributes to DOM properties, which use camelCase.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in JSX vs HTML: What's Actually Different?

Because JSX is JavaScript, and class is a reserved word. JSX uses className for the HTML class attribute to avoid the conflict. The same logic applies to htmlFor instead of for.

In HTML, style is a string. In JSX, style takes an object with camelCased keys like backgroundColor and fontSize, not kebab-case strings, because JSX maps attributes to DOM properties.

Yes. Every tag must be closed, either with a closing tag or as a self-closing tag with a slash. Tags like br and img that are unclosed in HTML still need the closing slash in JSX.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0