button name Attribute - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:button

Description

The name attribute sets the name for a <button> element which is used to reference form-data after the form has been submitted, or to reference the element in a JavaScript.

Attribute Values

Value Description
name The name of the button

Two buttons with equal names, that submit different values when clicked:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form action="/action_page.php" method="get">
Choose your favorite subject:<!--from w w  w . j  av a 2  s . co  m-->
<button name="subject" type="submit" value="HTML">HTML</button>
<button name="subject" type="submit" value="CSS">CSS</button>
</form>

</body>
</html>

Related Tutorials