Fragment
In one line
A Fragment is a special React element that groups multiple children without adding an extra wrapper DOM node.
In simple words
React components must return a single root element. Without Fragments, you'd have to wrap multiple elements in a <div>, which adds an unwanted extra node to the DOM — breaking CSS layouts, adding nesting, and confusing semantic HTML.
Fragments solve this. Write <>...</> (shorthand) or <React.Fragment>...</React.Fragment> to group children without a wrapper. The Fragment renders nothing to the DOM — its children appear as if they were returned directly.
The explicit <React.Fragment> form also accepts a key prop, which is useful when mapping a list where each item returns multiple elements.
Example
function Item() {
return (
<>
<dt>Term</dt>
<dd>Definition</dd>
</>
);
}
// No extra <div> in the DOM — just <dt> and <dd> directly.The Fragment groups <dt> and <dd> without adding a wrapper div, preserving the correct HTML structure for a definition list.
Related terms
Related Resources
Related Lessons
- Fragments
Learn Fragments for cleaner markup.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.