HTML Popover
What Is It?
A popover shows a small piece of extra information when someone presses a button.
What the Tags Mean
popover: marks the hidden content.popovertarget: matches the content’s ID.button: opens and closes it.
Example 1
Save each example as index.html and open it in your browser. Each code block is a complete page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Popover</title>
</head>
<body>
<button type="button" popovertarget="help">Need help?</button>
<div id="help" popover>Enter your full name.</div>
</body>
</html>Browser preview
What you see: Click Need help? to show the message. Click outside it or press Escape to close it in supporting browsers.
Example 2: Another Use
Use it for a short explanation of a fee.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Popover</title>
</head>
<body>
<button type="button" popovertarget="fee">What is included?</button>
<div id="fee" popover>Paper, tools, and one lesson.</div>
</body>
</html>Browser preview
Simple Tip
A popover does not block the whole page. Use a dialog when you need a modal decision.
Try It Yourself
Write a popover that explains a form field.