Popover

An HTML popover is a small window that appears upon clicking or hovering over an element, offering additional information or actions, often created with JavaScript or CSS.

HTML Popover

A popover is a small window that appears when a user clicks or hovers over an element, providing extra information or context. Popovers are often used to show tooltips, small forms, or other content without changing the page layout.

Syntax

index.html
<element popover>

HTML Popover Attribute

  • Purpose: The popover attribute creates a hidden content overlay that appears when triggered by another element.
  • Trigger: Usually a button or link with a popover-target attribute.
  • Global Use: Can be added to any editable HTML element.

Basic Setup

  • HTML
  • CSS

HTML

A trigger element and a popover element.

{.border-0}
Hello
index.html
<div popover id="myheader">Hello</div>
<button popovertarget="myheader">Click me!</button>

Behavior Modes

  • Auto: Dismisses popover when clicking outside.
  • Manual: Requires explicit closure.

Conclusion

A popover in HTML is a small, interactive element that appears when triggered by a user action like clicking or hovering. It displays additional content without disrupting the page layout. Common use cases include tooltips or small forms.