button form Attribute - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:button

Description

The form attribute sets one or more forms the button belongs to.

Attribute Values

Value Description
form_id Specifies the form element the <button> element belongs to.

The value of this attribute must be the id attribute of a <form> element in the same document.

A button is located outside a form but it is still a part of the form.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form id='my' action="/action_page.php" method="get">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>

  <button type="submit" formtarget="_blank">Submit to a new window/tab</button>
</form><!--  w w w  .  jav a 2s.  com-->

  <button form='my' type="submit">Submit</button>
</body>
</html>

Related Tutorials