Skip to content

Commit da7315f

Browse files
committed
DOC: clarify SSR metadata hoisting for fragments
1 parent 7b6c3ce commit da7315f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • src/content/reference/react-dom/components

src/content/reference/react-dom/components/title.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ To specify the title of the document, render the [built-in browser `<title>` com
3838

3939
React will always place the DOM element corresponding to the `<title>` component within the document’s `<head>`, regardless of where in the React tree it is rendered. The `<head>` is the only valid place for `<title>` to exist within the DOM, yet it’s convenient and keeps things composable if a component representing a specific page can render its `<title>` itself.
4040

41+
When using server rendering for only a fragment of a document (for example, rendering into a `<div id="root">`), React cannot move the `<title>` into the actual HTML `<head>` in the server response. For metadata that must be present in the initial HTML, render it in your server-side document template as well.
42+
4143
There are two exception to this:
4244
* If `<title>` is within an `<svg>` component, then there is no special behavior, because in this context it doesn’t represent the document’s title but rather is an [accessibility annotation for that SVG graphic](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title).
4345
* If the `<title>` has an [`itemProp`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemprop) prop, there is no special behavior, because in this case it doesn’t represent the document’s title but rather metadata about a specific part of the page.

0 commit comments

Comments
 (0)