html reset - Difference between<input type='submit' />and<button type='submit'>text</button>
bootstrap php (3)
<button>, you can use img tags, etc. where text is
<button type='submit'> text -- can be img etc. </button>
<input> type, you are limited to text
There are many legends about them. I want to know the truth. What are the differences between the two following examples?
<input type='submit' value='text' />
Not sure where you get your legends from but:
Submit button with
<button type="submit">(html content)</button>
IE6 will submit all text for this button between the tags, other browsers will only submit the value. Using
<button> gives you more layout freedom over the design of the button. In all its intents and purposes, it seemed excellent at first, but various browser quirks make it hard to use at times.
In your example, IE6 will send
text to the server, while most other browsers will send nothing. To make it cross-browser compatible, use
<button type="submit" value="text">text</button>. Better yet: don't use the value, because if you add HTML it becomes rather tricky what is received on server side. Instead, if you must send an extra value, use a hidden field.
<input type="button" />
By default, this does next to nothing. It will not even submit your form. You can only place text on the button and give it a size and a border by means of CSS. Its original (and current) intent was to execute a script without the need to submit the form to the server.
Normal submit button with
<input type="submit" />
Like the former, but actually submits the surrounding form.
Image submit button with
<input type="image" />
Like the former (submit), it will also submit a form, but you can use any image. This used to be the preferred way to use images as buttons when a form needed submitting. For more control,
<button> is now used. This can also be used for server side image maps but that's a rarity these days. When you use the
usemap-attribute and (with or without that attribute), the browser will send the mouse-pointer X/Y coordinates to the server (more precisely, the mouse-pointer location inside the button of the moment you click it). If you just ignore these extras, it is nothing more than a submit button disguised as an image.
There are some subtle differences between browsers, but all will submit the value-attribute, except for the
<button> tag as explained above.
<noscript> isn't even necessary, and not to mention not supported in XHTML.