What's the best practice to create a modern form, accessible etc? Especially, label vs placeholder fight

what'd
what w
how to pronounce what
what c
what p
what does
what h
what is love

I'm looking for advices and feedback, as I can't decide what's the way to go.

I'm building HTML5 form and I want them to be as easy as possible to use. That's why, I always used label to explain what to enter in a field, and placeholder as an example of a value with a good format.

So, my code always looks like:

<form>
    <fieldset>
        <p>
            <label for="origin-field">Please enter your origin address</label>
            <input type="text" name="origin" id="origin-field" placeholder="23th Street, New York City" required />
        </p>
        <p>
            <label for="destination-field">Please enter you destination address</label>
            <input type="text" name="destination" id="destination-field" placeholder="Ashbury Street, San Francisco" required />
        </p>
    </fieldset>
    <p>
        <input type="submit" />
    </p>
</form>

This code is accessible, labels are linked to inputs using the for attribute, in short, it respects the best practices. It has other UX advantages: if the user clicks in the input and then is distracted, the label is always displayed next to it and can easily remind them what information the input is waiting.

However, my product owner and my designer deeply want me to remove the label and use the placeholder instead, so the code would be

<form>
    <fieldset>
        <p>
            <input type="text" name="origin" id="origin-field" placeholder="Origin address" required />
        </p>
        <p>
            <input type="text" name="destination" id="destination-field" placeholder="Destination address" required />
        </p>
    </fieldset>
    <p>
        <input type="submit" />
    </p>
</form>

The two arguments are, it uses less space on screen / is more beautiful and also, users mistake the example value as something they could have entered and don't get why the field isn't empty (this is of course a contrast problem, the placeholder is light grey and should not be mistaken with a really value, in deep black, but eh, according to the PO, they do).

What should I do? Should I fight to try to keep the label in the design? If I put a display: none on the label, will it be still read by screen-readers? Should I put a position: absolute; left: -9999px; top: -9999px; instead?

What's the current best practice?


What, informal. a punishment or reprimand (esp in the phrase give (a person) what for) Quickly send and receive WhatsApp messages right from your computer.


Having just placeholder text instead of labels have some problems.

  1. Placeholder text disappears when user starts typing in the input field. Then it violates SC 3.2.2 as there's no visible label or instructions.
  2. When text is entered over top of the placeholder text, some Screen reader and browser combinations will populate the placeholder value as an accessible name in the Accessibility API when there is no other label in the code and some Screen readers don't. So they are not evenly supported yet.
  3. Even if labels are provided as Screen reader only or Offscreen text, it benefits SR users, but having no visual label is a problem for users with Cognitive disabilities, low attention deficit etc.

One solution would be to use Floating labels. These are place holder text that moves out of the input field to become a label when user starts typing.

What for definition and meaning, is commonly classified as an adjective if it is used to introduce a noun or a noun phrase. what definition: 1. used to ask for information about people or things: 2. used in questions that show you are…. Learn more.


Answering your questions:

What's the best practice to create a modern form, accessible etc? Especially, label vs placeholder fight

Use bootstrap and font awesome, if you combined them, you will get an awesome bootstraped form :) use form-group

What should I do? Should I fight to try to keep the label in the design? If I put a display: none on the label, will it be still read by screen-readers? Should I put a position: absolute; left: -9999px; top: -9999px; instead?

What's the current best practice?

Same as before, use bootstrap an get the things done with less effort. Please forget that kind of things like hidding stuff on the DOM because that is not SEO friendly :(

Bootstrap

Fontawesome

What Part of Speech is “WHAT”, that you want to tell something to the person you send this emoji to and you are hoping they won't get mad at you. It's almost like you want to bother someone with a request but you are either worried or feeling shy about it. unlimited authority, power, or influence of one person in any group. the technique, method, or system of operating or controlling a process by highly automatic means, as by electronic devices, reducing human intervention to a minimum.


Word, I will do what I can to help you. TranslationsEdit. show ▽what? (interrogative pronoun)  informal a punishment or reprimand (esp in the phrase give (a person) what for) 7. what have you someone, something, or somewhere unknown or unspecified: cars, motorcycles, or what have you. 8.


What does finger-pointing 👉🏽👈🏽 emoji mean on TikTok?, what definition: 1. used to ask for information about people or things: 2. used in questions that show you are…. Learn more. WhatsApp Messenger: More than 2 billion people in over 180 countries use WhatsApp to stay in touch with friends and family, anytime and anywhere. WhatsApp is free and offers simple, secure, reliable messaging and calling, available on phones all over the world.


what, Quickly send and receive WhatsApp messages right from your computer. This is the ORIGINAL "What What (In the Butt)" video. The South Park version aired over a year after we made this video. There's been a lot of confusion about this. We can assure you, we are not