Description

The HTML <button> element represents a clickable button. It is used to submit forms, trigger JavaScript actions, or create interactive UI elements.

Unlike the <input type="button"> element, the <button> element can contain rich content such as text, images, and icons, making it more flexible for interactive designs.

CSS Display:inline-block

Syntax

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

Examples

Basic Button
<button type="button">Click Me</button>
A simple button with no default action. Use JavaScript to add functionality.
Submit Button
<form> <input type="text" placeholder="Your name"> <button type="submit">Submit</button> </form>
A submit button inside a form. Clicking it submits the form data.
Disabled Button
<button type="button" disabled>Not Available</button>
A disabled button cannot be clicked or focused. It appears grayed out by default.

Notes

Always specify the type attribute. Without it, a button inside a form defaults to type="submit", which may cause unintended form submissions.

Prefer <button> over <a> for actions (like opening a modal or toggling a menu). Use <a> only for navigation. This is important for both accessibility and semantics.