Semantic input message inside label

I use <label>to transfer input so that its success and error messages are displayed inside its label for merging. What do you think is the most meaningful markup for this scenario?

<label>
  <b>Username</b>
  <input>
  <strong>Username already taken :(</strong>
</label>

strongSuitable for mistakes ? Or is it better span? Does it fit role=status?

+4
source share
5 answers

WCAG provides an example of error mapping using the aria-invalidand properties aria-describedby.

In your example, the code would look like this:

<label>
  <b>Username</b>
  <input aria-invalid="true" aria-describedby="error">
  <strong id="error">Username already taken :(</strong>
</label>

strong , . alert ( status) #error W3C.

+6

.

, - , , .

+2

, ( css). , , , , font-weight:bold; css.

, , Strong , , .

In general, I think that in this case it’s faster, easier and better to use <strong>over <span>.

+2
source

Strongly good, because "Username is already accepted" is a serious notification, not an accidental one.

+2
source

I would suggest keeping it a strong tag and also using a red CSS color to display it as an error.

+1
source

Source: https://habr.com/ru/post/1687179/


All Articles