popover
The popover
global attribute is used to specify that the element should be hidden on the page until it is opened by interacting with an invoking element (a <button>
or <input type="button">
with a popovertarget
), or manually via showPopover()
.
Usage notes
- When open, the element will appear above all other elements on a separate top layer, and won't be influenced by parent elements
position
oroverflow
styling. - The
:popover-open
CSS pseudo-selector can be used to style the element when it is open. - The
::backdrop
CSS pseudo-element can be used to style the backdrop that is displayed behind the element; for example, to dim unreachable content behind the modal dialog. <button>
elements can open a popover by adding thepopovertarget
attribute, with a value matching theid
of the element with thepopover
attribute.- The
beforetoggle
andtoggle
events can be used to determine when an element withpopover
will change from an open or closed state.
Examples
Simple example
The following will render a button which will open a popover element.
<button popovertarget="my-popover">Open Popover</button>
<div popover id="my-popover">Greetings, one and all!</div>
Specifications
Specification |
---|
HTML Standard # the-popover-attribute |
Browser compatibility
BCD tables only load in the browser
See also
- The
beforetoggle
event - The
toggle
event element.hidePopover()
element.showPopover()
element.togglePopover()
- The
:popover-open
pseudo-element - The
::backdrop
pseudo-element - popover-polyfill