--- title: JSX --- # JSX > JSX is short for JavaScript XML. JSX is an expression which uses valid HTML statements within JavaScript. You can assign this expression to a variable and use it elsewhere. You can combine other valid JavaScript expressions and JSX within these HTML statements by placing them within braces (`{}`). Babel further compiles JSX into an object of type `React.createElement()`. ### Single-line & Multi-line expressions Single-line expression are simple to use. ```jsx const one =

Hello World!

; ``` When you need to use multiple lines in a single JSX expression, write the code within a single parenthesis. ```jsx const two = ( ); ``` ### Using only HTML tags ```jsx const greet =

Hello World!

; ``` ### Combining JavaScript expression with HTML tags We can use JavaScript variables within braces. ```jsx const who = "Quincy Larson"; const greet =

Hello {who}!

; ``` We can also call other JavaScript functions within braces. ```jsx function who() { return "World"; } const greet =

Hello {who()}!

; ``` ### Only a single parent tag is allowed A JSX expression must have only one parent tag. We can add multiple tags nested within the parent element only. ```jsx // This is valid. const tags = ( ); // This is not valid. const tags = (

Hello World!

This is my special list:

); ``` ### All Tags Must Be Closed In HTML, there are self-closing tags such as `img`, `br`, `input`, and `hr`. This means that either of these methods are valid: ```html ``` Self-closing (sometimes referred to as **void**) tags can be rendered with or without a closing forward slash. However, with JSX, _all_ tags must be closed. The following JSX is invalid: ```javascript const email = ; ``` Closing the `input` tag will make the JSX valid: ```javascript const email = ; ``` ### More Information - [Introducing JSX](https://reactjs.org/docs/introducing-jsx.html)