You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/learn/writing-markup-with-jsx.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -228,7 +228,7 @@ For historical reasons, [`aria-*`](https://developer.mozilla.org/docs/Web/Access
228
228
229
229
JSX looks a lot like HTML, but a few attributes work slightly differently because JSX maps to JavaScript and DOM properties. This short reference explains the common differences and shows examples you can copy.
230
230
231
-
### Attribute name differences
231
+
### Attribute name differences {/*attribute-name-differences*/}
232
232
233
233
Some HTML attribute names are either reserved words in JavaScript or differ from the DOM property names. Use the React/JSX name when writing JSX:
234
234
@@ -240,7 +240,7 @@ Some HTML attribute names are either reserved words in JavaScript or differ from
240
240
<label htmlFor="email">Email</label>
241
241
```
242
242
243
-
### Boolean attributes
243
+
### Boolean attributes {/*boolean-attributes*/}
244
244
245
245
In HTML, boolean attributes are represented by their presence. In JSX, you pass explicit boolean values—but JSX also supports the shorthand form (which means `true`):
246
246
@@ -256,7 +256,7 @@ In HTML, boolean attributes are represented by their presence. In JSX, you pass
256
256
<input disabled />
257
257
```
258
258
259
-
### Inline styles
259
+
### Inline styles {/*inline-styles*/}
260
260
261
261
HTML uses a CSS string. JSX uses a JavaScript object with camelCased property names:
262
262
```html
@@ -272,7 +272,7 @@ Numeric values (like lineHeight, zIndex) can be written as numbers
272
272
<div style={{ lineHeight: 1.5, zIndex: 10 }} />
273
273
```
274
274
275
-
### Data and ARIA attributes
275
+
### Data and ARIA attributes {/*data-and-aria-attributes*/}
276
276
277
277
React preserves data-* and aria-* attributes exactly as they appear in HTML. These must remain dash-cased:
278
278
```jsx
@@ -284,7 +284,7 @@ React preserves data-* and aria-* attributes exactly as they appear in HTML. The
284
284
```
285
285
These attributes are ideal for accessibility and for storing custom data.
286
286
287
-
### Unknown or invalid attributes
287
+
### Unknown or invalid attributes {/*unknown-or-invalid-attributes*/}
288
288
289
289
React will not add invalid or unknown attributes to the DOM:
290
290
```jsx
@@ -305,7 +305,7 @@ function Button({ children, ...rest }) {
305
305
<Button data-track="1" disabled>Click</Button>
306
306
```
307
307
308
-
### Tips & common gotchas
308
+
### Tips & common gotchas {/*tips--common-gotchas*/}
309
309
310
310
- Use DOM property names (`className`, `htmlFor`, `defaultValue`) in JSX.
311
311
- Boolean attributes should use `true` or `false`, not strings.
0 commit comments