popover

The popover attribute is not part of standard HTML. Instead, you can utilize libraries or develop custom solutions to implement popover or tooltip features in web development.

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

index.html
<element popover>

Examples

The following renders a button that will open a popover element when activated.

{.border-0}
Greetings, one and all!
index.html
<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 attribute
  • popovertargetaction 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.