The <button> element defines a clickable button. This button does not submit input from a form, unless directed to do so by a javascript. In this example, the button is used to display an alert popup window when it is clicked on:
HTML file: | Displayed by browser: |
---|---|
<!DOCTYPE html>
<html> <body> <button type="button" onclick="alert('Hello World!')"><img src="../html_beg/images/smiley.gif" alt="Back button" style="height:42px;width:42px">Click Me!</button> </body> </html> |
Note: I found some debate over the differences between this button and the submit button. The most interesting is that the submit tag doesn't support HTML inside of it, since it's a single self-closing tag. The button tag, on the other hand, supports HTML elements inside, such as an image, because it's a tag pair. This makes it flexible when it comes to CSS styling. It is unfortunate that the button tag may not be recognized by older browsers.