Placeholder Text Color Override Not Working

Looking at this page, I’ve applied the following code which doesn’t seem to be overriding the placeholder text color:

.wpcf7 input[type="text"]::placeholder,
.wpcf7 input[type="text"]::-webkit-input-placeholder,
.wpcf7 input[type="text"]:-webkit-input-placeholder,
.wpcf7 input[type="text"]:-moz-placeholder,
.wpcf7 input[type="text"]::-moz-placeholder,
.wpcf7 input[type="text"]:-ms-input-placeholder,
.wpcf7 input[type="email"]::placeholder,
.wpcf7 input[type="email"]::-webkit-input-placeholder,
.wpcf7 input[type="email"]:-webkit-input-placeholder,
.wpcf7 input[type="email"]:-moz-placeholder,
.wpcf7 input[type="email"]::-moz-placeholder,
.wpcf7 input[type="email"]:-ms-input-placeholder,
.wpcf7 textarea::placeholder,
.wpcf7 textarea::-webkit-input-placeholder,
.wpcf7 textarea:-webkit-input-placeholder,
.wpcf7 textarea:-moz-placeholder,
.wpcf7 textarea::-moz-placeholder,
.wpcf7 textarea:-ms-input-placeholder { color: #333!important; opacity: 1!important; }

Hi there toad78,

instead of worrying about the arty farty colour of the “placeholder attribute”,
you should focus your attention, instead, on accessibility considerations.

Can We Stop Using Input Placeholders in Place of Labels?

coothead

7 Likes

Don’t comma separate prefixed styles because when a browser encounters a rule it doesn’t understand it should stop and go to the next rule block and ignore the current rule completely. It does not go to the next comma separated item.

If you separate them it works as shown below.

As @coothead said the consensus of opinion is now to avoid the placeholder completely.

Here is a point in question with your form. I have filled in all the details and am about to review before I submit.

Can you see what’s wrong with it?

It looks fine to me.

5 Likes

“Don’t Use The Placeholder Attribute” just recently came out, which is good that you mentioned it. Unfortunately, it wasn’t my call to use placeholders. I prefer labels, and I know that there’s a way to use the labels as ‘placeholders’. The client wanted a quick turnaround, though.

Thank you, gents!

I think placeholders can have some usefulness. I would not use them to replace a label, but I think they can be a help when a specific format is wanted for a text input.

For example, instead of a label like:

Date (enter 4 digit year, forward slash, 2 digit month, forward slash, 2 digit day) […]

Date [eg. 2018/06/28]

I do not think they should be relied on as a guarantee, but they could help reduce UI clutter and help users avoid failed submits.

4 Likes

In my mind that would be exactly the time that you should not use placeholders.:).

If the input requires a specific format then I want that to be present while I type because as soon as you start typing and the placeholder disappears I wont remember whether it was dashes or slashes as separators or whether the year was 4 digits or two. I’d need to delete the current input and double check what was needed and then type again. I’ve actually done that a number of times for real and its a real nuisance.:slight_smile:

Without wishing to derail the thread into a placeholder discussion the only useful purpose I can think of for a placeholder is to say something like ‘type here’ (assuming you have a proper label in place).

I’ve always thought that having a hint field that disappears as you type is of no use to anyone especially if autofill has filled all the fields for you but not with the correct information.

If the form needs a hint then it needs a hint that is always visible and that’s not the case for placeholder. When reviewing a form I want to know all fields are correct before posting and I can’t do that if placeholders have been used which show the format required.

The article I linked to above explains all these scenarios and taking into account all the things that can go wrong I now have to agree with the author. I used to think placeholders were ok as long as you had a label but now I’d rather not use them. I can see a small case where they add extra information over and above what was needed to complete the task but in cases of specific format and what type of data is required then I think that needs to be in the html (not necessarily in the label as such because labels should be more succinct).

3 Likes

True enough. I guess another way would be to avoid text inputs when a specific format is required. eg. a separate select each for year, month, day.

ie. if you don’t want users to enter “Jan, 23 2013”, “3-10-14” or other possible variants, don’t give them the opportunity to do so.

3 Likes

Yes I think we can make life easier if we idiot proof some of the data input. :slight_smile:

I suppose there’s a thin line between going overboard and making it too verbose as some users may get annoyed at jumping through too many hoops. It’s a bit of a conundrum and as yet I don’t think there’s a perfect answer other than trying to keep it simple.

4 Likes

Check out floating labels.

“Floating Labels” really are a bad idea. :rolleyes:

Forms are not a source of entertainment.

The floating label won’t make users enjoy using forms.
Users don’t care.
They just want the outcome.

Since the floating label doesn’t save any vertical space,
and other types of fields such as radio buttons and the
select element need a label anyway, why not just show
the label in the first place?

Do not let arty farty nonsense distract you from sensible
coding methods.

coothead

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.