HTML value Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The value attribute defines a default or associated value for an element. What that means depends on the tag — most often <input>, <button>, <option>, and <li>, plus <progress> / <meter>.

On text-like inputs, value is the initial text. On checkbox/radio and options, it is the data paired with name when the control is selected. Related: type, checked, selected, placeholder.

Baseline · Widely available.

Not deprecated and not experimental. A core form/control attribute supported everywhere modern browsers render HTML.

Not one meaning for every element.

Read value in context of the host tag. Do not confuse it with the obsolete valuetype attribute on <param>.

HTML Syntax

syntax.html
<element value=" string">

Examples: <input value="Ada">, <input type="checkbox" value="yes">, <option value="us">, <li value="10">. In JavaScript, many controls expose a live .value property.

Attribute Values

The attribute is a string (or number-like string). Common uses:

Element / useDescriptionTry it
input (text, email, …)Initial field contentsTry it
input checkbox / radioSubmitted value when checked (default often on)Try it
option / buttonData sent with the form for that choice/buttonTry it
li in olOrdinal number for that list itemTry it
progress / meterCurrent numeric measureTry it

Live Preview

Edit the field or apply a preset. Status shows the content attribute vs the live IDL .value.

presets

Typing updates IDL .value; the content attribute may stay at the original default.

Input

attr="Ada" · IDL="Ada"

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Default Text on an Input

Pre-fill a field the user can still edit.

HTML
<form>
  <label>Email
    <input type="email" name="email" value="[email protected]">
  </label>
  <button type="submit">Save</button>
</form>
Try It Yourself

How It Works

  1. Put value on the input — shown on first paint.
  2. User edits — live contents update via the IDL .value.
  3. On submit — the current contents are sent with name.
  4. Not a placeholder — real data, not a faded hint.

Example 2 — Checkbox and Option Values

What gets submitted when a choice is selected.

HTML
<form id="prefs">
  <label>
    <input type="checkbox" name="newsletter" value="yes" checked>
    Subscribe
  </label>

  <label>Country
    <select name="country">
      <option value="in">India</option>
      <option value="us" selected>United States</option>
    </select>
  </label>

  <button type="submit">Send</button>
</form>
<p id="out"></p>

<script>
  document.getElementById("prefs").addEventListener("submit", function (e) {
    e.preventDefault();
    var data = new FormData(this);
    document.getElementById("out").textContent =
      "newsletter=" + (data.get("newsletter") || "(off)") +
      ", country=" + data.get("country");
  });
</script>
Try It Yourself

How It Works

  1. Checkbox — if checked, sends newsletter=yes (not the label text).
  2. Unchecked — that name is usually omitted from the submit data.
  3. Option — visible label can differ from the value string.
  4. Always pair with name — otherwise nothing is submitted.

Example 3 — List Item and Progress

Same attribute name on non-text controls.

HTML
<ol>
  <li>First</li>
  <li value="10">Jumps to 10</li>
  <li>Then 11</li>
</ol>

<label>Upload
  <progress value="40" max="100">40%</progress>
</label>
Try It Yourself

How It Works

  1. li value — sets that item’s number in an ordered list; following items continue from there.
  2. progress value — current amount toward max.
  3. Different jobs — always check the element when you see value.
  4. Meter uses value similarly for a scalar gauge.

Edge Cases & Pitfalls

Most confusion is mixing the content attribute with the live IDL property, or forgetting checkbox defaults.

IDL

Attribute ≠ live .value

After typing, input.value changes, but getAttribute("value") may still show the original default. Use defaultValue when you mean the initial string.

checkbox

Missing value → "on"

A checked checkbox without value usually submits on. Set an explicit value for clear APIs.

placeholder

Not a placeholder

placeholder is a hint. Do not use value only to fake a placeholder — it submits as real data.

password

Avoid pre-filling secrets

Putting passwords in HTML value exposes them in source. Leave password fields empty.

valuetype

Different from valuetype

valuetype on <param> is a separate legacy attribute — not everyday form value.

Browser Support

value is a core HTML attribute for form controls and related elements. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

value

Supported everywhere modern browsers render HTML. Safe to rely on for defaults, submitted choice data, list ordinals, and progress measures.

98% Global support (approx.)
Google Chrome 1+
Full support
Mozilla Firefox 1+
Full support
Apple Safari 1+
Full support
Microsoft Edge 12+
Full support
Opera 4+
Full support
Samsung Internet Modern · Full
Full support
Internet Explorer 2+
Supported
value Widely supported

Bottom line: Safe for everyday forms. Remember element-specific meaning, and prefer explicit checkbox/option values over defaults.

Key Takeaways

  • Role: default or associated data for a control/element.
  • Text inputs: initial contents; submit the live field text.
  • Choices: what is sent when checkbox/radio/option is selected.
  • Context: same name, different jobs on li / progress.

One line: value is the control’s data — initial text, submitted choice string, or numeric measure — always read it for the element you are on.

Frequently Asked Questions

It depends on the element. On text-like inputs it sets the initial contents. On checkbox/radio and option it is the data sent when that control is chosen. On button it can be included when the form is submitted. On li it can set the ordinal number in an ordered list.
Related but not identical. After the user types, input.value (IDL) is the live contents. The value content attribute often still holds the original default until you change it in the DOM. Use defaultValue for the initial string on many inputs.
If checked and value is omitted, browsers typically submit the name with the value "on".
No. placeholder is a hint that disappears when the user types. value is real control data (default or current).
Common ones: input, button, option, li, progress, meter, and data. Meaning is element-specific — always check the element docs.
No. value is a standard, widely supported HTML attribute. (Do not confuse it with the obsolete valuetype attribute on param.)

Next: valuetype

Legacy param attribute — separate from everyday form value.

valuetype tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful