Debian Codegraph @

www/src/content/reference/02-headers/16-HX-Reselect.md

raw symbols SCIP
1 ---
2 title: "HX-Reselect"
3 description: "Override the content selection from the server"
4 ---
5
6 The `HX-Reselect` response header overrides which part of the response is used for swapping, replacing whatever `hx-select` was set on the triggering element.
7
8 ## Syntax
9
10 ```http
11 HX-Reselect: #content
12 ```
13
14 The value is a CSS selector applied to the response HTML to extract the content to swap in.
15
16 ## Example
17
18 Return a full page but tell htmx to only use a specific fragment:
19
20 ```python
21 return Response(
22 full_page_html,
23 headers={'HX-Reselect': '#main-content'}
24 )
25 ```
26
27 ## Notes
28
29 - Overrides `hx-select` on the source element
30 - Evaluated after the response is received, before swapping
31
32 See also: [`hx-select`](/reference/attributes/hx-select), [`HX-Retarget`](/reference/headers/HX-Retarget), [`HX-Reswap`](/reference/headers/HX-Reswap)