Explain Codes LogoExplain Codes Logo

Change text from "Submit" on input tag

html
responsive-design
best-practices
accessibility
Alex KataevbyAlex Kataev·Nov 30, 2024
TLDR

To change the default "Submit" text of a button in HTML, you need to modify the value attribute:

<input type="submit" value="Go">

The button will now display "Go" instead of "Submit".

Diving into button customization

Now that we've seen the quick solution, let us dig a bit deeper and understand how we can enhance our button customization further.

The power of the value attribute

The value attribute plays a vital role in label modification, it defines the text content on your button:

<input type="submit" value="Like">

Styling buttons using CSS classes

While a CSS class doesn't directly influence the button text, it greatly affects the button's look-and-feel:

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

In the code above, with the "like" class, we can apply custom CSS for a tailored visual appearance.

Versatility with the button element

An <input> tag sometimes falls short in flexibility, but the <button> element offers greater adaptability for detailed customizations:

<button type="submit">Like 👍</button>

Still, remember to consider legacy browser issues, as <button> might not work well on some old versions of Internet Explorer.

Avoiding customization pitfalls

Even with correct customizations, we must avoid some potential roadblocks while modifying our submit button.

Evading naming missteps

In terms of influencing the button's displayed text, name="submitBtn" attribute does not play a part. The name attribute shines when it comes to data processing in forms.

Maintaining accessibility

Make sure your custom text still makes sense to screen readers and retains accessibility for all users.

Enhancing user experience with button customization

Button text customization can improve user experience. Let's understand why and when this customization is helpful.

Reflective of action

The button text should reflect the intended action. "Search" for search forms, "Download" for download buttons. This boosts user interface intuitiveness.

Consistency with brand

Maintaining a consistent brand voice across your website creates a strong brand identity. Therefore, customizing button text to suit your brand voice is crucial.

Internationalization

For multilingual websites, changing the "Submit" with a term from the user's preferred language enhances their experience and accessibility.