Accepted answer

the for attribute is called htmlfor for consistency with the dom property api. if you're using the development build of react, you should have seen a warning in your console about this.


that is htmlfor in jsx and class is classname in jsx


just using react htmlfor to replace for!

since for is a reserved word in javascript, react elements use htmlfor instead.


you can find more info by following the below links.


both for and class are reserved words in javascript this is why when it comes to html attributes in jsx you need to use something else, react team decided to use htmlfor and classname respectively


for react you must use it's per-define keywords to define html attributes.

class -> classname

is used and

for -> htmlfor

is used, as react is case sensitive make sure you must follow small and capital as required.


yes, for react,

for becomes htmlfor

class becomes classname


see full list of how html attributes are changed here:

Related Query

More Query from same tag