×

HTML5 Button Tag

HTML Button Tag

The < button > tag is used on the webpage to construct a clickable button inside the HTML. Within the < button>....</button > tag, we can place content like text or picture.

The type attribute to a < button > tag should always be defined. For the button item various browsers use different default type.

You are required to use HTML button tag inside and outside the form. If you use it inside the form, it will act like the submit button. It can also be used as a reset button.

You can call the JavaScript feature on it, while using the outside type.

HTML Button Tag Sample

Let's look at the code that shows the button.

<button name="button" type="button">sign in</button>

Output:

HTML Button Tag

HTML Button Example: Submit Form

Let's see the code to click on button to Submit form.

<form>
Enter First Name:<input type="text" name="name"/><br/>
Enter Second Name:<input type="text" name="name"/><br/>
Gender:<input type="text" name="name"/><br/>
<button>Submit Form</button>
</form>

Output:

HTML Button Tag

HTML Button Example: Calling JavaScript Function

Let's see the code to click on button to call JavaScript feature.

<button name="button" value="OK" type="button" onclick="hello()">Press me</button>
<script>
function hello(){ 
alert("Hii Tutorialandexample"); 
} 
</script>

Output:

HTML Button Tag
HTML Button Tag

HTML Button Example: Reset Form

Let's see the code to click on button to reset form.

<form>
Type Your First Name:<input type="text" name="name"/><br/>
Type Your Last Name:<input type="text" name="name"/><br/>
<button type="reset">reset</button>
</form>

Output:

HTML Button Tag

Attributes of HTML Button Tag

The <button> tag accepts all the global attributes and even some additional unique attributes.

A list of attributes with the HTML button tag is given.

AttributeDescription
DisabledIt defines deactivation of a button.
FormactionIt is used for form submission. It determines where to send data about the form when submitting the form.
AutofocusThis specifies that while loading the page a button will automatically get attention.
NameIt specifically states of the button name.
ValueIt specifies button value.
FormtargetAfter submitting the form, it determines where to display the answer.
FormenctypeIt defines how to encode the form-data before it is sent to server.
FormmethodThis sets out how the form-data will be submitted.
FormIt defines one or more forms which belong to the click.
FormnovalidateIt determines that the data on the form will not be validated after submission.
typeIt specifically states button type.
<button accesskey="">It defines click keyboard shortcut. As for HTML5, this attribute is global and can be used on any item.
TabindexDetermines the selection order by using the Tab key.

Supporting Browsers

Internet ExplorerChromeFirefoxOpera

Related Topics

HTML Elements

An HTML element is nothing but a starting tag and then some content and then the closing tag. So we can say HTML elements is everything from the starting tag...

3 minutes read.

Responsive HTML5 and CSS3 Tutorial

Introduction to HTML5 Tutorial HTML5 is the latest and upgraded version of HTML. HTML is a hypertext markup language. Technically, it is not a programming language. It is a markup language. HTML...

17 minutes read.

Html &lt;Col> Tag

You can write the col tag inside the table tag after the thead, tbody, foot, and tr tags. You can also apply it after the caption tag (in which the...

4 minutes read.

HTML &lt;body> alink Attribute

HTML <body> alink Attribute What is HTML? The HTML or HyperText Markup Language is used to design web pages. The file extension name for HTML file is ".html". It was released in...

2 minutes read.

HTML Anchor

HTML Anchor The HTML anchor tags define a hyperlink that links to other pages on one page. It can create hyperlinks to any web page and files, locations or any other...

3 minutes read.

HTML <select> tag

This tag helps in making the drop-down list on the web page. This is highly used in HTML forms for taking the input from user. You can use the id attribute...

3 minutes read.

HTML Charsets

In this tutorial, we are going to discuss about the charsets in the HTML. The letters, numbers, and several other symbols are shown correctly by the web browser. All of this...

2 minutes read.

HTML Links

It consist of anchor element which is used to create a link between a source anchor and destination anchor. The anchor tag can be embedded between text, image, video or...

2 minutes read.

HTML5 Button Tag

HTML Button Tag The < button > tag is used on the webpage to construct a clickable button inside the HTML. Within the < button>....</button > tag, we can place content...

2 minutes read.

HTML Attributes

HTML Attributes provide the additional information about HTML elements. Attributes are always specified in the start tag. Attributes usually comes in pairs. lang Attribute This attribute helps in declaring the language...

2 minutes read.

HTML <video> Tag

The Video tag in HTML is used to play video on a media player on the web page. We can also insert an audio by the video tag, but audio...

6 minutes read.

HTML <summary> tag

When we simply want to show the primary heading or topic name of hidden detailed material to users, then we can achieved this by using the summary tag. This makes it...

2 minutes read.

HTML Unordered List

In HTML, we have <ul> tag which defines the unordered list. And it is also known as bulleted list, because as we know it is not ordered list therefore it...

2 minutes read.

HTML Headings

The titles and subtitles of our webpages are known as HTML headings. Let’s not talk about webpages but giving heading to almost everything like normal paragraphs, articles or let it...

2 minutes read.

How to add JavaScript to HTML

JavaScript is one of the most important languages today. It is a high-level, interpreted, lightweight programming language that makes web pages more interactive. It is a language of the web....

5 minutes read.

Div Tag in HTML

In HTML, ‘div’ is a tag that specifies division or section in HTML document. But before going in detail of it, let’s first understand about tags in HTML. The tag...

8 minutes read.

HTML5 Attribute

HTML Attribute HTML attributes are special words that provide additional information about the HTML element or attributes.The element or tags have attributes, which define the element's behavior.It also adds attributes with a start...

3 minutes read.

HTML <samp> tag

The Samp tag in HTML is used for defining the sample output from the computer program. This tag is a phrase type tag and a container tag that means the...

2 minutes read.

HTML Background Image

Inserting image in HTML An image (technically digital image) in HTML or even in general technical aspects, is a binary representation of visual information. By visual information we mean, in the...

8 minutes read.

How to append HTML code to a div using JavaScript?

In HTML, we have a div tag which is used to create a box where we can put a lot of other tags. So it works like a container. So,...

4 minutes read.