0

I have created an input field for a log-in feature on the page however I have been trying to change the color of the text in the field using css. Is this possible. I have tried many routes however none seem to work so far. Below is the code for the email portion of the sign in.

 <input class="form-control ng-class:{'error':dashboard.showFormErrors && !dashboard.signinForm.email.$valid}"
               data-ng-model="signinController.signin.email"
               type="email"
               name="email"
               id="email"
               placeholder="Email"
               ng-minlength="2"
               ng-maxlength="3"
               required>
3
  • It would be great if you could accept an answer, if any, that solve your question, or let us know what is missing, so we can find one that does Commented Jun 19, 2016 at 18:07
  • I posted the answer/solution that I used on the bottom of the page. Commented Jun 20, 2016 at 19:29
  • An answer already had focus as a suggestion, accept that instead of post an answer of your own using the very same Commented Jun 20, 2016 at 20:16

7 Answers 7

6

Yes, it is possible.

The CSS can target the input of type "email" or just this unique input.

Email input element:

input[type=email]{
    color: red;
}

Or specific id="email":

#email {
    color: red;
}

Here's a snippet:

input[type=email] {
  color: red;
}
#email2 {
  color: green;
}
<input class="form-control ng-class:{'error':dashboard.showFormErrors && !dashboard.signinForm.email.$valid}" 
       data-ng-model="signinController.signin.email" 
       type="email" 
       name="email" 
       id="email" 
       placeholder="Email" 
       ng-minlength="2" 
       ng-maxlength="3" 
       required>
<input class="form-control ng-class:{'error':dashboard.showFormErrors && !dashboard.signinForm.email.$valid}" 
       data-ng-model="signinController.signin.email" 
       type="email" 
       name="email" 
       id="email2" 
       placeholder="Email"
       ng-minlength="2"
       ng-maxlength="3" 
       required>

If this still isn't working, you may have to use the "!important" attribute to override other CSS setters.

color: red !important;
Sign up to request clarification or add additional context in comments.

Comments

3

I think you can do this in your css file :

#email{
  color:red;
}

You can give color of your choice.

Comments

1

Create a css class that holds the changes you want to do to the fields , and then affect the class to the input tags via ng-class directive. In your code the syntax is wrong I think.. but that's the idea.

Comments

1

You can apply the following code input { color: red; }

Comments

1

Many of your suggestions work great. This is the route I used with css

input, select, textarea{
    color: #076000;
}

textarea:focus, input:focus {
    color: #076000;
}

Comments

0

It is definitely possible that you can change your input's text color with CSS and there are quite some ways to that depending upon the result you want to achieve.

For example, if you want to set your colour to blue and have it always stay blue, you can use the following code:

#email {
    color: blue; /* Or color: #0000ff */
}

Alternatively, if you want to change your text's colour when your selected input has focus, you can use this instead:

#email:focus {
    color: blue; /* Or color: #0000ff */
}

You can also change your colour on hover, but this is not something that is used very often:

#email:hover {
    color: blue; /* Or color: #0000ff */
}

Comments

0

To change input color for different types of input use respective tag (with/without its pseudo state)

input, select, textarea {
    color: #000;
}
input:focus, input:active

/* etc... */

input[type=text] - will only select text fields
input[type=password] - will only select password fields
input[type=number] - will only select number fields
/* etc.. */

input[type=text]:focus
/* etc */

For placeholder styling

::-webkit-input-placeholder {
   color: red;
}

:-moz-placeholder { /* Firefox 18- */
   color: red;  
}

::-moz-placeholder {  /* Firefox 19+ */
   color: red;  
}

:-ms-input-placeholder {  
   color: red;  
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.