C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
HTML Button TagThe <button> tag is used to create a clickable button within HTML form on your webpage. You can put content like text or image within the <button>........</button> tag. You should always specify the type attribute for a <button> tag. Different browsers use different default type for the button element. HTML Button tag can be used inside and outside the form. If you use it inside the form, it works as the submit button. You can also use it as reset button. If you use it outside the form, you can call JavaScript function on it. HTML Button Tag ExampleLet's see the code to display the button. <button name="button" type="button">Click Here</button> Output: HTML Button Example: Calling JavaScript FunctionLet's see the code to call JavaScript function on button click. <button name="button" value="OK" type="button" onclick="hello()">Click Here</button> <script> function hello(){ alert("hello TheDeveloperBlog user"); } </script> Output: HTML Button Example: Submit FormLet's see the code to submit form on button click. <form> Enter Name:<input type="text" name="name"/><br/> <button>Submit</button> </form> Output: HTML Button Example: Reset FormLet's see the code to submit form on button click. <form> Enter Name:<input type="text" name="name"/><br/> <button type="reset">reset</button> </form> Output: Attributes of HTML Button Tag<button> tag supports all global attributes and some specific additional attributes. There is given a list of HTML button tag attributes.
Supporting Browsers
HTML button tag also supports the global and event attributes in HTML.
Next TopicHTML canvas Tag
|