HTML Tip: You can create a simple popover without JavaScript.
A popover is like a small dropdown or popup that appears when the user clicks a button. This can be useful for menus, extra details, profile links, settings, and more.
In this example:
  1. The button has popovertarget="menu".
That tells the browser which popover to open. The value "menu" matches the id of the popover.
  1. The <div> has id="menu" and the popover attribute.
The id="menu" connects it to the button. The popover attribute tells the browser, “This element should behave like a popover.”
The cool part is that the browser handles opening and closing it for you.
This is a great reminder that HTML can do more than just structure a page. Sometimes it gives us built-in features that save us from writing extra JavaScript.
3
0 comments
Rob Vanarsdall
7
HTML Tip: You can create a simple popover without JavaScript.
The Code Zone Skool
skool.com/the-code-zone
Beginner-friendly community to learn Python, HTML, CSS, & JavaScript. We help you become a full-stack developer and offer 1:1 code coaching.
Leaderboard (30-day)
Powered by