HTML button tag

By | March 13, 2020

In this chapter we will learn about <button> tag of HTML. If we want to create a button in a web page, we take the button tag. Button tag has a starting tag and an end tag.

<button>..........</button>

If we need to create a form inside our web page, then we need a button in the form to submit it. For which we take the button tag, we can insert any text or image inside the button. After taking the button tag, we should always put the attribute in the button like this.

<button type="button">.....</button>

We can use the HTML button tag inside and outside the form. The button tag inside the form tag acts as a submit button tag, outside of the form, a JavaScript function call is placed above the button tag.

Browser Support:-

All modern browsers support the button tag of HTML.

Attributes:-

Value Attribute Description
textvalueSpecifies an initial value for the button

button
reset
submit
type Specifies the type of button
namename Specifies a name for the button

_blank
_self
_parent
_top
framename
formtarget Specifies where to display the response after submitting the form. Only for type=”submit”
formnovalidate formnovalidate
Specifies that the form-data should not be validated on submission. Only for type=”submit”
get
post
formmethod Specifies how to send the form-data (which HTTP method to use). Only for type=”submit”
application/x-www-form-urlencoded
multipart/form-data
text/plain
formenctype Specifies how form-data should be encoded before sending it to a server. Only for type=”submit”
URLformaction Specifies where to send the form-data when a form is submitted. Only for type=”submit”
form_idform Specifies which form the button belongs to
disabled disabled Specifies that a button should be disabled
autofocus autofocus Specifies that a button should automatically get focus when the page loads

Example:-

<button type="button">Click button</button>

Output:-

 <form>
    	<input type="text" placeholder="Enter Name">
    	<input type="email" placeholder="Enter Email">
    	<button type="submit">Submit</button>
    </form>

Output:-

for job
learn coding
for result in india
Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *