6

I want to change the button text for 'New Service Request' to white. Please advise.

.btn-info { background: #0066cc; border: none; border-radius: 3px; font-size: 18px; padding: 10px 20px; }

.btn-info:hover{

background: #003366;

transition: 0.5s background;}
<button class="btn-info"> <a href="LINK">New Service Request</a></button>

4
  • 1
    Do you want change text color white when mouse hover? Commented Dec 6, 2019 at 2:54
  • 2
    Does this answer your question? How to set text color in submit button? Commented Dec 6, 2019 at 3:26
  • 1
    @chandu.komati I don't think that's related as their issue that it is a button with an a nested within it. Targetting the button with CSS won't modify the font-color as per the linked example. The only answer is to target the a within the button using CSS. Commented Dec 6, 2019 at 3:27
  • 1
    your HTML is invalid, a cannot be inside a button element Commented Dec 6, 2019 at 8:28

7 Answers 7

3

You need to set the color of the a tag within the button to white.

Example:

.btn-info {
  background: #0066cc;
  border: none;
  border-radius: 3px;
  font-size: 18px;
  padding: 10px 20px;
}

.btn-info:hover {
  background: #003366;
  transition: 0.5s background;
}

.btn-info a {
  color: white;
}
<button class="btn-info"> <a href="LINK">New Service Request</a></button>

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

Comments

2

You simply need to target .button-info a to change the color of your text to white.

<style>

.btn-info { background: #0066cc; border: none; border-radius: 3px; font-size: 18px; padding: 10px 20px; }

.btn-info a, .btn-info:hover {
  color: white;
}

.btn-info:hover{

background: #003366;

transition: 0.5s background;}

</style>

<button class="btn-info"> <a href="LINK">New Service Request</a></button>

It's worth noting too that your HTML is invalid, the nested structure <button><a></a></button> is not accepted, and can be checked by a Markup Validation Service. See the error below:

Error: The element a must not appear as a descendant of the button element.

A valid and more succinct version of your code is as follows:

<style>
  .btn-info {
    background: #0066cc;
    border: none;
    border-radius: 3px;
    font-size: 18px;
    padding: 10px 20px;
    color: white;
  }
  
  .btn-info:hover {
    background: #003366;
    transition: 0.5s background;
    cursor: pointer;
  }

</style>

<input type="button" class="btn-info" onclick="location.href='http://google.com';" value="Google" />

Comments

1

Change your class button-info to white You can do something like this. Hope it helps

.btn-info { 
background: #0066cc; 
border: none; 
border-radius: 5px; 
font-size: 14px; 
padding: 10px 10px; }

.btn-info a {
  color: #fff;
  text-decoration: none;
}

.btn-info:hover{
background-color: #003366;
}
<button class="btn-info"> <a href="LINK">New Service Request</a></button>

Comments

1

Remove the a tag altogether, and give the hover state of the button a rule of cursor: pointer:

.btn-info {
  background: #0066cc;
  border: none;
  border-radius: 3px;
  font-size: 18px;
  padding: 10px 20px;
  color: #fff;
}

.btn-info:hover {
  background: #003366;
  transition: 0.5s background;
  cursor: pointer;
}
<button class="btn-info">New Service Request</button>

Comments

1

try this one

.btn-info
{
    font-size: 13px;
    color:green;
}

<button class="btn-info"> <a href="LINK">New Service Request</a></button>

Comments

0

You should target the inside .button-info class to change the color of your text.

Comments

0
try this code: 

    .btn-info { background: #0066cc; border: none; border-radius: 3px; font-size: 18px; padding: 10px 20px; }

    .btn-info:hover{
    color: #fff;
    background: #003366; 

    transition: 0.5s background;}



    <button class="btn-info" href="LINK">New Service Request</button>

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.