3

HTML code:-

<p><input type="text" placeholder="Username"></p>

CSS code:-

.main-header input
{
    width: 90%;
    padding: 1rem;
    margin: 20px 0px;
    border: none;
    border-bottom: 4px solid #5f5fb0;
    font-size: 1.3rem;
    background: transparent;
    outline: none;
}
::-webkit-input-placeholder
{
    color: #fff;
}

I want to change the color to #fff(white) of the text given by the user in the input box on the webpage. In this project, I am using HTML and CSS. I had tried very much but I can not make the color white.

Please help me to solve this problem.

2 Answers 2

2

I think you mean this.
You can change it to .main-header input.

input[type="text"]
{
    width: 90%;
    padding: 1rem;
    margin: 20px 0px;
    border: none;
    border-bottom: 4px solid #5f5fb0;
    font-size: 1.3rem;
    background: black;
    outline: none;
    color: white;
}
::-webkit-input-placeholder
{
    color: #fff;
}
<p><input type="text" placeholder="Username"></p>

Sign up to request clarification or add additional context in comments.

3 Comments

And change "background-color: transparent;".
Thank you, Sir, I have tried your code and it works properly
You are welcome. can you approve my answer? Thank you. ;)
1

Just give the color to the input tag's selector itself the color property

input {
  color: white;
  background-color: black;
}
<input type="text">

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.