1

In an MVC application, I need to display links rendered by @Html.ActionLink as buttons. I have the following code in site.css:

.linkbutton {
       font-family: Constantia, Georgia, serif;
       text-align:justify;
       padding-left: 22px;
       background-color:#FF7F00;  
       color:#fff;     
       border: 1px solid #333;
       cursor: pointer;
       font-size:1.2em;       
       width: auto;
       height:auto;        
}

In the view I used a table layout for the links and referred the linkbutton class as:

  <td class="linkbutton">
      @Html.ActionLink("Add Cab", "Create")
   </td>

The link is using the styles from the .linkbutton class. However, the text color that needs to be in white (#fff) is not inherited, despite being defined as color:#fff; in the CSS. Instead the default blue link color with an underline is getting displayed. I need the link to appear with white font color and without the underline.

In CSS I tried:

 a.linkbutton.link {
     /*Style code*/
 }

Then refer it from the view as:

 Html.ActionLink("Add Cab", "Create", new {@class = "linkbutton"}). 

But, it is not working. Please help.

2
  • Try setting color:#fff !important; Commented Jul 21, 2014 at 7:29
  • Try a { color:inherit; }. Note a.linkbutton.link does not exist - it would be .linkbutton a {.. Commented Jul 21, 2014 at 7:32

1 Answer 1

1

You can override the rules for links inside .linkbutton element, so instead of

a.linkbutton.link {
    /*Style code*/
}

write

.linkbutton a {
    color: #fff;
    text-decoration: none;
}
Sign up to request clarification or add additional context in comments.

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.