--- id: jsx-in-depth title: JSX in Depth permalink: jsx-in-depth.html prev: displaying-data.html next: jsx-spread.html --- [JSX](http://facebook.github.io/jsx/) is a JavaScript syntax extension that looks similar to XML. You can use a simple JSX syntactic transform with React. ## Why JSX? You don't have to use JSX with React. You can just use plain JS. However, we recommend using JSX because it is a concise and familiar syntax for defining tree structures with attributes. It's more familiar for casual developers such as designers. XML has the benefit of balanced opening and closing tags. This helps make large trees easier to read than function calls or object literals. It doesn't alter the semantics of JavaScript. ## HTML Tags vs. React Components React can either render HTML tags (strings) or React components (classes). To render a HTML tag, just use lower-case tag names in JSX: ```javascript var myDivElement =
; React.render(myDivElement, document.getElementById('example')); ``` To render a React Component, just create a local variable that starts with an upper-case letter: ```javascript var MyComponent = React.createClass({/*...*/}); var myElement = ; React.render(myElement, document.getElementById('example')); ``` React's JSX uses the upper vs. lower case convention to distinguish between local component classes and HTML tags. > 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. ## The Transform React JSX transforms from an XML-like syntax into native JavaScript. XML elements, attributes and children are transformed into arguments that are passed to `React.createElement`. ```javascript var Nav; // Input (JSX): var app =