0

I am using the following style for placeholder, but it turns the input text (when i start typing) to start from right to left. Now i am seeing this example, it is just text-align, but why mine is formatting wrong? Here is the fiddle for my example

input[placeholder="Required"]{
    text-align: right;
}
andreas
  • 16,357
  • 12
  • 72
  • 76
localhost
  • 822
  • 2
  • 20
  • 51

2 Answers2

6

Your selector input[placeholder="Required"] selects an input with a placeholder attribute, not the placeholder itself.

Use the selectors given in your example:

input::-webkit-input-placeholder {
  text-align: right;
}
input::-moz-placeholder {
  text-align: right;
}
input::-ms-input-placeholder {
  text-align: right;
}
input::placeholder {
  text-align: right;
}
<form method="post">
  <div class="blocks">
    <label for="fullname">Full Name</label>
    <input type="text" id="fullname" name="name" placeholder="Required">
  </div>
  <div class="blocks">
    <label for="Email">Email Address</label>
    <input type="Email" id="Email" name="email" placeholder="Required">
  </div>
</form>
andreas
  • 16,357
  • 12
  • 72
  • 76
1

Because in the example it styles the placeholder and not the input element (like you do).

input[placeholder="Required"]::-moz-placeholder{ text-align: right; }
input[placeholder="Required"]::-ms-input-placeholder{ text-align: right; }
input[placeholder="Required"]::-webkit-input-placeholder{ text-align: right; }

Updated demo: https://jsfiddle.net/z1zuo69q/2/

Gabriele Petrioli
  • 191,379
  • 34
  • 261
  • 317