/    Sign up×
Reference /Pin to ProfileBookmark

The button tag defines an interactive element that performs an action when activated.

Syntax

The type attribute should always be specified, so the browser will know what type of button it is.

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

Attributes

autofocus
Designates that a button should focus on page load.

disabled
Designates that a button should be disabled.

form
Tells the browser which form ID the the button belongs to.

formaction
Provides the URL to send the form data when a form is submitted and the button type="submit".

formenctype
Provides the method of encoding used (application/x-www-form-urlencoded, multipart/form-data, or text/plain) for the form-data before sending it to a server. Only used when button type="submit".

formmethod
Designates which HTTP method to use (get or post) to send the form-data. Only used when button type="submit".

formnovalidate
Specifies to not validate the form-data when it is submitted. Only used when button type="submit".

formtarget
Designates where to open the form response after submission (_blank, _self, _parent, or _top). Only used when button type="submit".

name
Designates the button’s name.

type
Designates what type of button it is (button, reset, or submit).

value
Designates the initial value for the button.

Browser Compatibilty

Demos

User-submitted codepen.io examples of <button>

@steime

See the Pen on CodePen.

Want to Contribute?

Submit a codepen.io link that demonstrates <button>:

to submit a demo.
HTML
×

Success!

Help @reference spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...