CKTIS / HTML
popovertarget — identifying a target popover
The popovertarget attribute connects a button to a popover element through its id. It enables showing and hiding that element without JavaScript.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
popovertarget="popover-id"popovertarget identifies the element controlled by a button or an input with type="button". An input must be in the Button state, so submit, reset, and image inputs are not eligible. Its value is the target's id, without #, not a CSS selector. The target must have a popover attribute and be in the same tree.
The separate popovertargetaction attribute selects the action: toggle switches visibility, show reveals, and hide conceals. A missing or invalid value means toggle. popovertarget alone does not make the target a popover.
Use type="button" to avoid form submission. Disabled buttons and submit buttons associated with a form do not activate this mechanism. A nonexistent target or a target without popover also will not work.
Whenever possible, place the target immediately after its button in the DOM to preserve logical reading order. In the example, popover="auto" also allows dismissal by clicking outside it.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Popover target</title>
<button type="button" popovertarget="details">Toggle details</button>
<div id="details" popover="auto">Additional details.</div>
</html>Result
Initially: only “Toggle details” is visible. First button activation: “Additional details.” becomes visible. Second activation: it is hidden again.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.