HTML Button Tag

The <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 Example

Let’s see the code to display the button.

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

HTML Button Example: Calling JavaScript Function

Let’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 javatpoint user");  

}  

</script>

Comments

Leave a Reply

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