how to make a button in html

Table of Contents

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.

Example of Button:

Note: button act like link not working in codepen plz copy the code in your html and check it.

<button >this is simple button</button>
 <button type="button" disabled>disabled button!</button>
 <button onclick="alert('You are clicking on me');"> alert on click</button> 
// button act like link not working in codepen plz copy the code in your html and check it.
 <button onclick="window.location.href='https://www.w3schools.com/tags/tag_a.asp';" > 
button act like link</button>

 

 

 

HTML Button tag can be used inside and outside the form.

 

Attribute Value Description
autofocus autofocus Specifies that a button should automatically get focus when the page loads
disabled disabled Specifies that a button should be disabled
form form_id Specifies one or more forms the button belongs to
formaction URL Specifies where to send the form-data when a form is submitted. Only for type=”submit”
formenctype application/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how form-data should be encoded before sending it to a server. Only for type=”submit”
formmethod get
post
Specifies how to send the form-data (which HTTP method to use). Only for type=”submit”
formnovalidate formnovalidate Specifies that the form-data should not be validated on submission. Only for type=”submit”
formtarget _blank
_self
_parent
_top
framename
Specifies where to display the response after submitting the form. Only for type=”submit”
name name Specifies a name for the button
type button
reset
submit
Specifies the type of button
value text Specifies an initial value for the button

Leave a Comment

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

No data found.