Pregunta

I am building a multilingual website and I was wondering how is set the default value of a submit button? Is it something browser specific or does it rely on the system language or both? ie : I'm just asking if I've to set a specific value according to the language of the page or if it will be done automatically? I've been unable to find anything about that in the w3c specs. Thanks!

¿Fue útil?

Solución

The HTML 4.01 specification is rather vague about this, but the HTML5 CR is more explicit. It says, in the description of <input type=submit>: “If the element has a value attribute, the button's label must be the value of that attribute; otherwise, it must be an implementation-defined string that means "Submit" or some such.” This does not specify that the string should be language-dependent in any sense, but in practice it usually depends on the language of the browser.

The conclusion that you should always set the value attribute, to make sure it is in the language of the page and, moreover, that it is informative. Quite often, a generic name that means “submit” is too abstract.

On the technical side, the value of a submit button is undefined if there is no value attribute. This means that the getAttribute() method yields null and the value property of the element node is the empty string. However, on form submission, browsers in practice act as if the value were the string that they use as button label.

Otros consejos

If a value is missing, the browser will place it there (in the language that the browser is in).

So assuming you don't know the language of the browser, it's best to just set the value attribute yourself.

Also, it's more consistent to have a translation for every text used in the website (which includes buttons).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top