HTML name Attribute

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

Definition and Usage

On form controls (<input>, <textarea>, <select>, <button>), the name attribute is the key sent with the control’s value when the form is submitted. Treat it as required for any field you want on the server — with no name (or an empty one), the value is not submitted.

The same attribute also groups radio buttons, names a <form>, targets an <iframe>, and pairs with content on <meta>. It is not the same as id — use id for labels and CSS; use name for submission and groups.

Baseline · Widely available.

Not deprecated and not experimental. Supported everywhere modern browsers run forms and metadata.

No name → no submit value.

A beautiful labeled input without name never reaches the server. Always set a clear name on fields you care about.

HTML Syntax

syntax.html
<input name=" key">
<meta name=" metadata-name" content="value">

key is a non-empty string for form controls. Prefer simple tokens like email or user_name.

Attribute Values

A string whose meaning depends on the element:

ContextWhat name meansTry it
Form controlsSubmission key for that field’s value (e.g. email)Try it
Radio / checkbox groupsShared name groups controls; radios allow one selectionTry it
<meta>Metadata type; pair with content (e.g. description)Try it
<iframe> / <form>Targetable browsing-context name, or form name in document.formsTry it

Live Preview

Change the field’s name, then submit. Navigation is blocked so you can read the key/value pair.

Demo only — shows what would be sent as the parameter name.

Form field

Would submit email=alex%40example.com

HTML Examples

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

Example 1 — Name Form Fields for Submit

Give each control a name so its value is included in the request.

HTML
<form action="/signup" method="post">
  <label for="email">Email:</label>
  <input type="email" id="email" name="email" required>

  <label for="password">Password:</label>
  <input type="password" id="password" name="password" required>

  <button type="submit">Sign up</button>
</form>
Try It Yourself

How It Works

  1. name="email" becomes the parameter key on submit.
  2. id connects the <label for> — different job from name.
  3. Both fields named so email and password reach the server.
  4. Empty name would drop that field from the payload entirely.

Example 2 — Radio Buttons Share a Name

Same name groups radios so only one option can be selected.

HTML
<fieldset>
  <legend>Plan</legend>
  <label><input type="radio" name="plan" value="free" checked> Free</label>
  <label><input type="radio" name="plan" value="pro"> Pro</label>
  <label><input type="radio" name="plan" value="team"> Team</label>
</fieldset>
Try It Yourself

How It Works

  1. Shared name="plan" creates one radio group.
  2. Different value on each option tells the server which choice was made.
  3. Only the checked radio is submitted (as plan=pro, for example).
  4. fieldset + legend keeps the group accessible.

Example 3 — Meta name + content

Document-level metadata uses name for the key and content for the value.

HTML
<head>
  <meta charset="UTF-8">
  <meta name="description" content="Learn the HTML name attribute for forms and metadata.">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>HTML name Attribute</title>
</head>
Try It Yourself

How It Works

  1. name says which metadata you are setting.
  2. content holds the actual string value.
  3. description often appears in search snippets; viewport helps mobile layout.
  4. Not a form field — this use is document metadata, not submit keys.

Edge Cases & Pitfalls

Most bugs are missing names, mixing up id, or clashing with form APIs.

submit

Missing or empty name

That control’s value is omitted from the form data. Always name fields the server needs.

compare

name is not id

id must be unique in the page. name can repeat (radios/checkboxes). Labels use for → id.

api

Avoid names that clash with form properties

Names like submit, reset, or length can override built-ins on form.elements / the form object.

special

_charset_ and isindex

A hidden input named _charset_ gets the submit encoding automatically. The name isindex is not allowed for historical reasons.

groups

Different radio names = different groups

If each radio has a unique name, they no longer act as one choice list. Share the name within a group.

Browser Support

name is an HTML attribute used across forms, meta, and framing in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

name

Supported in all mainstream browsers for form controls, meta, iframe, and related elements.

99% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported
name Universally supported

Bottom line: Safe to rely on everywhere. Remember: no name means the field value is not submitted.

Key Takeaways

  • Forms: name is the submit key for a control’s value.
  • vs id: id for labels/CSS; name for data and radio groups.
  • Radios: same name = one group; different value per option.
  • Meta: name + content for page-level metadata.

One line: name is how the browser labels form data (and some metadata) — without it, submit skips the field.

Frequently Asked Questions

It sets the key used when the control’s value is submitted with the form. Without a name (or with an empty name), that control’s value is not included in the submission.
id uniquely identifies an element in the document for labels, CSS, and getElementById. name is mainly for form submission and for grouping radios/checkboxes. You often need both.
Radios with the same name form one group — only one can be selected. The checked button’s value is submitted under that shared name.
Commonly input, textarea, select, button, and form. Also meta (with content), iframe (as a target name), map, object, param, and others.
Yes. Named controls appear on form.elements (for example form.elements.email). Avoid names that clash with built-in form properties like submit.
On meta, name identifies the kind of metadata and content holds the value — for example name="description" content="…".

Next: nohref

Legacy area attribute — prefer modern image-map patterns.

nohref 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.

14 people found this page helpful