Lukas Asked: 2020-03-29 06:41:04 +0800 CST 2020-03-29 06:41:04 +0800 CST 2020-03-29 06:41:04 +0800 CST How to add a placeholder to a div? 772 I have a divthat makes of textareaand I need a placeholder... This doesn't work for me: <div placeholder="El texto va aquí"></div> html 1 Answers Voted Best Answer lois6b 2020-03-29T06:43:18+08:002020-03-29T06:43:18+08:00 I found this answer from SOeng but it doesn't "look" very good divand I added a border: In it cssputs content:attr(placeholder)but if you want to call your attribute textoDentro="Texto aqui"in it you csshave to putcontent:attr(textoDentro) [contentEditable=true]:empty:not(:focus):before{ content:attr(placeholder) } div { width: 300px; height: 100px; border: 1px solid #ccc; padding: 5px; overflow: auto; } <div contentEditable=true placeholder="Tu texto aqui"></div>
I found this answer from SOeng but it doesn't "look" very good
div
and I added aborder
:In it
css
putscontent:attr(placeholder)
but if you want to call your attributetextoDentro="Texto aqui"
in it youcss
have to putcontent:attr(textoDentro)