Aral Code

Forms Lesson 34 of 42

HTML Buttons, Details, Dialog, Progress and Meter

Make buttons, show-and-hide sections, pop-up dialogs, progress bars and gauges using built-in HTML elements, with very little or no JavaScript.

Some HTML elements do more than display text. They react when people click or tap them. In this lesson you'll learn the interactive elements that work with plain HTML: buttons, details (show/hide), dialog (pop-up box), and two kinds of bars: progress and meter.

The button element

A <button> is a clickable button. The text between the tags is what people see on it.

Example A simple button
<button>Pabili po!</button>
<button disabled>Out of stock</button>

The disabled attribute grays the button out so it can't be clicked. That's useful for "Out of stock" items or a "Submit" button before a form is complete.

The three button types

Every button has a type. It matters most when the button is inside a form:

  • type="submit" — sends the form. This is the default inside a <form>.
  • type="reset" — clears everything the user typed back to the starting values.
  • type="button" — does nothing by itself. It's used with JavaScript.
Example Button types inside a form
<form>
  <label>Pangalan: <input name="name"></label>
  <p>
    <button type="submit">Ipasa (Submit)</button>
    <button type="reset">Burahin (Reset)</button>
    <button type="button" onclick="alert('Hello! This button runs JavaScript.')">Say hello</button>
  </p>
</form>

Button or link?

A simple rule: if clicking takes you to another page, use a link (<a href>). If clicking does an action on the same page (send, open, add, delete), use a <button>. You can style a link to look like a button with CSS, but keep the right element underneath. Screen readers announce them differently, and keyboard users expect them to behave differently.

Details and summary: show and hide

The <details> element creates a section that opens and closes when clicked, with no JavaScript needed. The <summary> inside it is the part that's always visible.

Example An FAQ with details
<h3>Frequently Asked Questions</h3>
<details>
  <summary>When is the enrollment period?</summary>
  <p>Enrollment for SY 2026–2027 runs from June 1 to June 15, Monday to Friday, 8 AM to 4 PM.</p>
</details>
<details>
  <summary>What documents should I bring?</summary>
  <p>Bring your report card (SF9), PSA birth certificate, and two 1x1 ID pictures.</p>
</details>
<details open>
  <summary>Is there a uniform?</summary>
  <p>Yes. The uniform is required starting the second week of classes.</p>
</details>

Click each question to open it. The open attribute makes a section start already opened. This element is perfect for FAQs, answer keys ("Click to see the answer"), and long instructions that not everyone needs.

Example A hidden answer for practice
<p><strong>Question:</strong> What is 15% of ₱200?</p>
<details>
  <summary>Show answer</summary>
  <p>₱30, because 200 × 0.15 = 30.</p>
</details>

Dialog: a pop-up box

The <dialog> element is a box that appears on top of the page. It stays hidden until it is opened. Opening it needs one line of JavaScript, showModal(). Closing it can be done with plain HTML, using a form with method="dialog".

Example A confirmation dialog
<button type="button" onclick="document.getElementById('confirm').showModal()">Delete my project</button>

<dialog id="confirm">
  <p><strong>Sigurado ka ba?</strong></p>
  <p>Your project will be deleted and cannot be brought back.</p>
  <form method="dialog">
    <button value="cancel">Cancel</button>
    <button value="yes">Yes, delete</button>
  </form>
</dialog>

A "modal" dialog blocks the rest of the page until it is closed, and the page behind it gets darker. Pressing Esc also closes it. Any button inside a <form method="dialog"> closes the dialog when clicked.

Progress: how far along?

<progress> shows how much of a task is done, like a loading bar. It has two attributes: value (how much is done) and max (the total).

Example Progress bars
<p>Downloading module: <progress value="70" max="100">70%</progress> 70%</p>
<p>Lessons finished: <progress value="12" max="42">12 of 42</progress> 12 of 42</p>
<p>Loading…: <progress></progress></p>

A progress bar with no value (like the last one) becomes an "indeterminate" bar that moves back and forth. It means "we're working on it, but we don't know how long it will take." The text between the tags is a fallback for very old browsers.

Meter: a measurement in a range

<meter> looks similar but means something different. It shows a measurement within a known range, like a fuel gauge, a battery level, or a score. Besides min, max and value, it can have low, high and optimum. The browser uses these to color the bar green, yellow or red.

Example Meters with colors
<p>Phone battery: <meter value="0.85" min="0" max="1" low="0.2" high="0.8" optimum="1">85%</meter> 85%</p>
<p>Phone battery: <meter value="0.15" min="0" max="1" low="0.2" high="0.8" optimum="1">15%</meter> 15% — charge na!</p>
<p>Storage used: <meter value="58" min="0" max="64" low="40" high="55" optimum="0">58 of 64 GB</meter> 58 of 64 GB</p>

Progress or meter?

  • Progress: a task moving toward being finished (downloading, uploading, steps completed).
  • Meter: a value that can go up and down within a range (battery, disk space, temperature, a test score).

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. Inside a form, what does a <button> with no type do when clicked?
2. Which element creates a show/hide section without JavaScript?
3. You want to show how much of a file upload is done. Which element fits?
4. You want to show a phone's battery level. Which element fits best?
5. Clicking a button should take the user to the Contact page. What should you use?

By Sir Reyel · Last updated 2026-12-04