summaryrefslogtreecommitdiffstatshomepage
path: root/www/content/attributes/hx-history-elt.md
blob: 0df474c35b1c60171df7b682433bf1c4a1fba3aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
+++
title = "hx-history-elt"
+++

The `hx-history-elt` attribute allows you to specify the element that will be used to snapshot and
restore page state during navigation.  By default, the `body` tag is used.  This is typically
good enough for most setups, but you may want to narrow it down to a child element.  Just make
sure that the element is always visible in your application, or htmx will not be able to restore
history navigation properly.


Here is an example:

```html
<html>
<body>
<div id="content" hx-history-elt>
 ...
</div>
</body>
</html>
```

## Notes

* `hx-history-elt` is not inherited
* In most cases we don't recommend narrowing the history snapshot