Skip to content

Why are attribute names "class" and "for" discouraged? #4331

Closed
@callumlocke

Description

@callumlocke

From the docs:

Note:
Since JSX is JavaScript, identifiers such as class and for are discouraged as XML attribute names. Instead, React DOM components expect DOM property names like className and htmlFor, respectively.

But the JSX compiler seems to be smart enough to quote keys like "class" and "for" (so they'll work fine even in pre-ES5 environments). So what's the problem? Why are they discouraged, and what exactly does that mean?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions