html5 Site Icon CSS3 Site Icon CSS Site Icon

HTML4 Reference

HTML <button> tag

Definition

The <button> tag is used to define a clickable button.

Example


<button name="aName">ButtonText</button>

Required Attributes

NONE

Optional Attributes

disabled - specifies the button will be disabled until a certain condition occurs.


<!-- Valid value disabled -->
<button disabled="disabled">ButtonText</button>

name - specifies a name for the button.


<button name="aName">ButtonText</button>

type - specifies a name for the button.


<!-- Valid values are button, reset and submit -->
<button type="button">ButtonText</button>
<button type="reset">ButtonText</button>
<button type="submit">ButtonText</button>

value - specifies a value for the button.


<button value="aValue">ButtonText</button>

Common Attributes

accesskey - specifies a keyboard shortcut to an element.


<button accesskey="aKey">ButtonText</button>

class - specifies a classname for the element allowing you to apply the style of the predefined class to the content.


<button class="classname">ButtonText</button>

id - specifies a unique id for the element allowing you to apply the style of the predefined id to the content.


<button id="idname">ButtonText</button>

style - specifies an inline style for the element allowing you to apply the style to the content.


<button style="color:red;text-align:left">ButtonText</button>

title - specifies extra information about the content.


<button title="information about the content">ButtonText</button>

Language Attributes

dir - specifies the directional flow of the content.


<!-- The text will flow from left to right -->
<button dir="ltr"">ButtonText</button>

<!-- The text will flow from right to left -->
<button dir="rtl">ButtonText</button>

lang - specifies a language code for the content of the element.


<button lang="en">ButtonText</button>

xml:lang - specifies a language code for the content of the element in XHTML documents.


<button xml:lang="fr">ButtonText</button>

Document Event Attributes

NONE

Form Event Attributes

onblur - The JavaScript code to be run when an element loses focus.


<!-- Executes the go() function -->
<button onblur="go()">ButtonText</button>

onfocus - The JavaScript code to be run when an element loses focus.


<!-- Executes the go() function -->
<button onfocus="go()">ButtonText</button>

Image Event Attributes

NONE

Keyboard Event Attributes

onkeydown - The JavaScript code to be run when an element is in focus and keyboard key is pressed.


<!-- Executes the go() function -->
<button onkeydown="go()">ButtonText</button>

onkeypress - The JavaScript code to be run when an element is in focus and keyboard key is pressed down and released.


<!-- Executes the go() function -->
<button onkeypress="go()">ButtonText</button>

onkeyup - The JavaScript code to be run when an element is in focus and keyboard key is released.


<!-- Executes the go() function -->
<button onkeyup="go()">ButtonText</button>

Mouse Event Attributes

onclick - The JavaScript code to be run when a mouse is clicked on the element.


<!-- Executes the go() function -->
<button onclick="go()">ButtonText</button>

ondblclick - The JavaScript code to be run when a mouse is double clicked on the element.


<!-- Executes the go() function -->
<button ondblclick="go()">ButtonText</button>

onmousedown - The JavaScript code to be run when the mouse button is pressed down while the cursor is over the element.


<!-- Executes the go() function -->
<button onmousedown="go()">ButtonText</button>

onmousemove - The JavaScript code to be run when the mouse button is moved.


<!-- Executes the go() function -->
<button onmousemove="go()">ButtonText</button>

onmouseout - The JavaScript code to be run when the mouse cursor moves off an element.


<!-- Executes the go() function -->
<button onmouseout="go()">ButtonText</button>

onmouseover - The JavaScript code to be run when the mouse cursor moves over an element.


<!-- Executes the go() function -->
<button onmouseover="go()">ButtonText</button>

onmouseup - The JavaScript code to be run when the mouse button is released while the cursor is over the element.


<!-- Executes the go() function -->
<button onmouseup="go()">ButtonText</button>


<br /> tag    << Prev          Next >>   <caption> tag

go to home page Homepage go to top of page Top

HTML Elements

The complete set of HTML elements also known as HTML tags from the latest HTML 4.01 Specification.

Click the links for more information on individual tags and their attributes.

<!--...-->

<!DOCTYPE>

<a>

<abbr>

<acronym>

<address>

<applet>

<area />

<b>

<base />

<basefont />

<bdo>

<big>

<blockquote>

<body>

<br />

<button>

<caption>

<center>

<cite>

<code>

<col />

<colgroup>

<dd>

<del>

<dfn>

<dir>

<div>

<dl>

<dt>

<em>

<fieldset>

<font>

<form>

<frame />

<frameset>

<h1> - <h6>

<head>

<hr />

<html>

<i>

<iframe>

<img />

<input />

<ins>

<isindex />

<kbd>

<label>

<legend>

<li>

<link />

<map>

<menu>

<meta />

<noframes>

<noscript>

<object>

<ol>

<optgroup>

<option>

<p>

<param />

<pre>

<q>

<s>

<samp>

<script>

<select>

<small>

<span>

<strike>

<strong>

<style>

<sub>

<sup>

<table>

<tbody>

<td>

<textarea>

<tfoot>

<th>

<thead>

<title>

<tr>

<tt>

<u>

<ul>

<var>