HTML <button> formtarget Attribute

Example A form with two submit buttons. The first submit button submits the form data with default target (“_self”), and the second submits the form data to a new window (target=”_blank”): <form 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” >Submit</button> <button type=”submit” formtarget=”_blank”>Submit to a new window</button> </form> Try it Yourself » Definition and Usage The formtarget attribute specifies where […]

HTML <button> name Attribute

Example Two buttons with equal names, that submit different values when clicked: <form action=”/action_page.php” method=”get”> Choose your favorite subject: <button name=”subject” type=”submit” value=”HTML”>HTML</button> <button name=”subject” type=”submit” value=”CSS”>CSS</button> </form> Try it Yourself » Definition and Usage The name attribute specifies the name for a <button> element. The name attribute is used to reference form-data after the form has been submitted, or to reference the […]

HTML <button> type Attribute

Example Two button elements that act as one submit button and one reset button (in a form): <form 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” value=”Submit”>Submit</button> <button type=”reset” value=”Reset”>Reset</button> </form> Try it Yourself » Definition and Usage The type attribute specifies the type of button. Tip: Always specify the type attribute for the <button> element. Different browsers may use different default […]

HTML <button> formenctype Attribute

Example A form with two submit buttons. The first submit button submits the form data with default character encoding, and the second submits the form data without character encoding: <form action=”/action_page_binary.asp” method=”post”> Name: <input type=”text” name=”fname” value=”Ståle Refsnes”><br> <button type=”submit”>Submit with character encoding</button> <button type=”submit” formenctype=”text/plain”>Submit without character encoding</button> </form> Try it Yourself » Definition and Usage The formenctype attribute specifies how form-data should […]

HTML <button> formaction Attribute

Example A form with two submit buttons. The first submit button submits the form data to “action_page.php”, and the second submits to “action_page2.php”: <form 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”>Submit</button><br> <button type=”submit” formaction=”/action_page2.php“>Submit to another page</button> </form> Try it Yourself » Definition and Usage The formaction attribute specifies where to send the form-data when a form is submitted. […]

HTML <button> form Attribute

Example A button located outside a form (but still a part of the form): <form action=”/action_page.php” method=”get” id=”form1″> First name: <input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname”><br> </form> <button type=”submit” form=”form1″ value=”Submit”>Submit</button> Try it Yourself » Definition and Usage The form attribute specifies one or more forms the button belongs to. Browser Support The numbers in the table specify the first browser version that fully supports […]

HTML <button> Tag

Example A clickable button is marked up as follows: <button type=”button”>Click Me!</button> Try it Yourself » Definition and Usage The <button> tag defines a clickable button. Inside a <button> element you can put content, like text or images. This is the difference between this element and buttons created with the <input> element. Tip: Always specify the type […]