0

I'm trying to change a placeholder in an html input (a text shown when no text is yet typed in the input field). Unfortunately, I don't have access to change the HTML file so I can't change it there. I only have access to the CSS file. Is there a way to change or hide the current placeholder text? It looks like this in HTML:

placeholder="example"
Hajo Brandt
  • 113
  • 7

2 Answers2

0

You can not change the value of the HTML using CSS, you can only style the HTML using CSS. Hence the name, "Cascading Style Sheets".

So the answer to your questions is that it is impossible to change the placeholder value using css.

However if you have access to JavaScript, you would be able to change the value of the placeholder attribute.

koder613
  • 1,486
  • 5
  • 21
-1

Like our friend koder613 said, you can easily achieve this with javascript. The code is posted, and I'm sorry if your code doesn't have access to js.

<!DOCTYPE html>
<html>
<body>

First Name: <input type="text" id="myText" placeholder="Name">

<p>Click the button to change the placeholder text of the text field.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
  document.getElementById("myText").placeholder = "Type name here..";
}
</script>

</body>
</html>
coder9927
  • 180
  • 12