English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML 参考手册

HTML 标签大全

HTML: <input> name 属性

name属性指定 <input>元素的名称,name属性用于引用JavaScript中的元素,或在提交表单后引用表单数据。

 HTML <input> Tag

在线示例

具有三个输入字段的HTML表单;两个文本字段和一个提交按钮:

!DOCTYPE html>
<html>
<head>
<title>HTML:<input> name 属性 - 基础教程网(oldtoolbag.com)</title>
<body>
<form action="action_page.php">
  Name: <input type="text" name="fullname"><br>
  Email: <input type="text" name="email"><br>
  <input type="submit" value="Submit">
</form>
</html>
Test and see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the name attribute.

Definition and Usage

The name attribute specifies the name of the <input> element.

The name attribute is used to reference elements in JavaScript or to reference form data after the form is submitted.

Note: Only form elements with the name attribute will pass their values when the form is submitted.

HTML 4.01 and HTML5Differences between

None.

Syntax

<input name="text">

Attribute Value

ValueDescription
textSpecify the name of the <input> element.
 HTML <input> Tag