| 1 | --- |
| 2 | title: "HX-Target" |
| 3 | description: "The element that will receive the response" |
| 4 | --- |
| 5 | |
| 6 | The `HX-Target` request header identifies the element that will receive the response. |
| 7 | |
| 8 | This header is only included when a target is specified. |
| 9 | |
| 10 | Format: `<tag>#<id>` (e.g. `div#results`) or just `<tag>` for elements without an ID. |
| 11 | |
| 12 | ## Syntax |
| 13 | |
| 14 | The header is included as follows: |
| 15 | |
| 16 | ```http |
| 17 | HX-Target: div#results |
| 18 | ``` |
| 19 | |
| 20 | ## Usage |
| 21 | |
| 22 | Return different content for different targets: |
| 23 | |
| 24 | ```python |
| 25 | target = request.headers.get('HX-Target') |
| 26 | if target == 'div#sidebar': |
| 27 | return render_template('sidebar_content.html') |
| 28 | ``` |