Change text from "Submit" on input tag


Html Problem Overview

I have a tag, <input type="submit" class="like"/>. I want to have the text inside the button say "Like", but right now, it says "Submit".

class="like" is the CSS of the button, by the way.

Html Solutions

Solution 1 - Html

The value attribute on submit-type <input> elements controls the text displayed.

<input type="submit" class="like" value="Like" />

Solution 2 - Html

The value attribute is used to determine the rendered label of a submit input.

<input type="submit" class="like" value="Like" />

Note that if the control is successful (this one won't be as it has no name) this will also be the submitted value for it.

To have a different submitted value and label you need to use a button element, in which the textNode inside the element determines the label. You can include other elements (including <img> here).

<button type="submit" class="like" name="foo" value="bar">Like</button>

Note that support for <button> is dodgy in older versions of Internet Explorer.

Solution 3 - Html

<input name="submitBnt" type="submit" value="like"/>

name is useful when using $_POST in php and also in javascript as document.getElementByName('submitBnt'). Also you can use name as a CS selector like input[name="submitBnt"]; Hope this helps


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1261817View Question on Stackoverflow
Solution 1 - HtmlRy-View Answer on Stackoverflow
Solution 2 - HtmlQuentinView Answer on Stackoverflow
Solution 3 - HtmlbashleighView Answer on Stackoverflow