Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[questions/qa-translate-flag] Empty string for the translate attribute #528

Open
xfq opened this issue Sep 4, 2023 · 2 comments
Open

[questions/qa-translate-flag] Empty string for the translate attribute #528

xfq opened this issue Sep 4, 2023 · 2 comments

Comments

@xfq
Copy link
Member

xfq commented Sep 4, 2023

[source] (https://www.w3.org/International/questions/qa-translate-flag) [en]

The attribute can appear on any element, and it takes just two values: yes or no.

From the HTML Standard:

The attribute's keywords are the empty string, yes, and no. The empty string and the yes keyword map to the yes state. The no keyword maps to the no state. In addition, there is a third state, the inherit state, which is the missing value default and the invalid value default.

Should we mention that the value of the translate attribute can also be an empty string?

@r12a
Copy link
Contributor

r12a commented Sep 4, 2023

I'm inclined no to. This article is aimed at content authors, rather than a complete description of how to process the attribute as a machine. I can't see a reason why a content author would need to know that a missing value will simply not change the current setting. (Note btw that the blank string is called the 'missing value default' and the 'invalid value default', so i think it's also ok to say that there are only 2 values (even though, for the parser, there are 3 states).

@xfq
Copy link
Member Author

xfq commented Sep 5, 2023

I can't see a reason why a content author would need to know that a missing value will simply not change the current setting.

An empty value means yes, and no translate attribute means inheriting the translate attribute value of the parent element, so they are different.

(Note btw that the blank string is called the 'missing value default' and the 'invalid value default', so i think it's also ok to say that there are only 2 values (even though, for the parser, there are 3 states).

I don't think that's the case. The empty string is a valid keyword. Note that the missing value default applies only when the attribute is missing, not when it is present with an empty string value. (See the second note in HTML § 2.3.3 Keywords and enumerated attributes.) The 'invalid value default' state do not apply in this case either.

Many other HTML attributes have similar behaviour, and I've seen many content authors rely on this behaviour, since attributes without a value are implied to be an empty string by the HTML standard, like:

  • People use <a download> for <a download="">
  • People use <input disabled> for <input disabled="">

In this case, <span translate> <=> <span translate=""> <=> <span translate="yes"><span>, since the parent element of the <span> may have translate="no".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants