Hx-target attribute
The hx-target attribute identifies the HTML element whose content or element HTMX updates with a request response.
Django in Action
hx-target is an HTMX attribute that identifies the HTML element whose content or element is affected by an HTMX response.
- How it is used
- Directs HTMX responses into a selected page region for dynamic updates without a full-page reload.
- How deep it goes
- Defines selector-based targeting and demonstrates it in a search template with partial-rendering Django views.
- Examples
- Uses a musician search input targeting a results div and an infinite-scroll results partial.
- What you can do after
- Apply it via HTMX to route a Django view’s partial HTML response into a selected element.
Quarkus in Action
The hx-target attribute identifies the HTML element whose contents HTMX replaces with a response.
- How it is used
- Directs an HTMX request’s HTML response to the intended page element.
- How deep it goes
- Shows ID-based targeting in working markup and forms; does not elaborate other target expressions.
- Examples
- Uses a greeting button, an availability search form, and a car reservation form.
- What you can do after
- Apply it via HTMX to update a chosen page region from a backend response.
Related concepts
- CSS selectoruses · A CSS selector is a pattern that identifies document elements by their names, attributes, relationships, states, or other conditions.
- HTMXconfigured by · HTMX is a JavaScript library that enables HTML attributes to initiate HTTP interactions, handle events, and update portions of a page.
- hx-trigger attributeconfigured by · The hx-trigger attribute specifies the browser events and timing conditions that cause HTMX to issue a request or refresh an element.
- HTMX attributekind of · An HTMX attribute is a declarative HTML attribute that specifies client-side HTTP interactions, events, targets, or updates handled by HTMX.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

