| 1 | --- |
| 2 | title: "HX-Retarget" |
| 3 | description: "Override the swap target from the server" |
| 4 | --- |
| 5 | |
| 6 | The `HX-Retarget` response header overrides the element that will receive the swapped content, replacing whatever `hx-target` was set on the triggering element. |
| 7 | |
| 8 | ## Syntax |
| 9 | |
| 10 | ```http |
| 11 | HX-Retarget: #new-target |
| 12 | ``` |
| 13 | |
| 14 | The value is a CSS selector for the new target element. |
| 15 | |
| 16 | ## Example |
| 17 | |
| 18 | Redirect a form submission result to a different container: |
| 19 | |
| 20 | ```python |
| 21 | return Response( |
| 22 | content, |
| 23 | headers={'HX-Retarget': '#notifications'} |
| 24 | ) |
| 25 | ``` |
| 26 | |
| 27 | ## Notes |
| 28 | |
| 29 | - Overrides `hx-target` on the source element |
| 30 | - Evaluated after the response is received, before swapping |
| 31 | |
| 32 | See also: [`hx-target`](/reference/attributes/hx-target), [`HX-Reswap`](/reference/headers/HX-Reswap) |