popover
popover Attribute
The popover
global attribute identifies an element as a popover. Popovers are initially hidden (using display: none
) and can be shown through a control element or by calling the HTMLElement.showPopover()
method.
- Behavior: Popovers display on top of other elements and are unaffected by the styling of their parent elements.
Syntax
<element popover>
Examples
The following renders a button that will open a popover
element when activated.
<button popovertarget="my-popover">Open Popover</button>
<div popover id="my-popover">Greetings, one and all!</div>
Attribute Values
- The
auto
setting (default) allows popovers to be dismissed by clicking outside of them and typically restricts the display to one popover at a time. - The
manual
setting requires popovers to be closed explicitly, allowing for multiple or nested popovers, such as in menus.
See also
- Popover API
popovertarget
HTML attributepopovertargetaction
HTML attribute::backdrop
CSS pseudo-element:popover-open
CSS pseudo-class
Conclusion
The popover
attribute in HTML is used to identify elements that can act as popovers, typically hidden by default and displayed via user interaction. While not a standard HTML feature, it can be implemented using JavaScript or libraries to show or hide content on top of other elements. Popovers can be set to auto or manual behavior, offering flexible control over their display and dismissal.
ping
The HTML ping attribute designates URLs that will be notified when a user clicks a link, enabling tracking without affecting the user's browsing experience.
rel
In HTML, the rel attribute specifies the relationship between the current document and a linked resource, such as a stylesheet, noopener, or noreferrer.