×

html · level 3 · unit 6 · lesson 2

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

makes a note that pops up on top of the page.

Add the popover attribute to any element and it hides. Give it an id, then give a <button> a popovertarget with that id. Pressing the button shows the popover on top of everything else.

Popovers close by : click anywhere outside, or press Esc. Pressing the button again closes it too.

Want separate buttons to open and close it? Add popovertargetaction="show" to one and popovertargetaction="hide" to the other. The browser makes it all work with the keyboard as well.

<p>Delivery is free over £30.
  <button popovertarget="delivery-info">How it works</button>
</p>
<div id="delivery-info" popover>
  <h2>Free delivery</h2>
  <p>Spend £30 or more in one order and we deliver free anywhere in Leeds.</p>
</div>

Press show my page to see it here.

A popover starts hidden, so the page looks the same until someone presses the button.