Placeholder in textarea is not showing

I am experimenting with survey form a little, and for now I have a very little idea, why for textarea place holder is not visible.

For other inputs placeholders are visible and I can’t figure out what’s up with textarea.

For now I’ve tried to give some color to textarea, give color to ::placeholder via pseudo-selector. Not helped.

This is an interesting one.

Click in the textarea and look at where the cursor is positioned.
Then hit the backspace key until you get to the beginning of the line.

Your placeholder should appear.

It seems that the new line in your html between the textarea opening and closing tags is interpreted as input text in the textarea.
If you delete that new line (and any spaces) between the opening/closing tags, that should fix the problem.

(I found this explanation in this (very old) SO thread ).

3 Likes

Yep, that’s actually because of spaces in the HTML. Thanks!
Its all good if code looks like below

<textarea name ="suggestions" rows="5" cols="40" placeholder="I have soooo many..."></textarea>

With any symbols between textarea’s tags placeholder isn’t visible.

That’s actually annoying. I am a big fan of code indentation and I don’t want opening and closing tag on the same line.

I sympathise.
In my code, I’ve got this on its own line:
></textarea>

Maybe that’s something you could live with?

1 Like

Yeah, this I can manage)

hi there,
how about this?


.

i was able to use the next line for the closing tag, going sure there is no space in front of closing tag.

2 Likes

Yeah, good stuff) I just tried, it worked.

But the thing is:
in your code textarea opening tag and other lines of code have 2 space indentation.

In my code for survey form I use 4-space indent, and its pretty deep nested, this will not look pretty at all for me)

1 Like

So the problem’s specific to space before the closing tag?
That’s useful to know.

Like @admit8490 though, I don’t like the way this version messes up my indentation.
I think I’ll stick with my original solution.

1 Like

thx. for your reply.
Now i can understand why you can live with the solution above. : )