10

Here's a piece of my HTML code

<div id = "mydiv">
    <% = Html.ActionLink("Some Text","SomeAction")%>
</div>

I'd like to style it in white so that it doesn't conflict with the background, which is also blue. So I did this:

#mydiv {background-color:blue;} 
#mydiv a:link { color:white}

But, it doesn't work -- the color it's still blue. How can I do it? Maybe, I just did not write well the selectors.

Thanks for helping.

7 Answers 7

10
#mydiv a { color:white; }
Sign up to request clarification or add additional context in comments.

Comments

10

Remove the :link suffix and you should be fine:

#mydiv { background-color:blue; }
#mydiv a { color:white; }

Alternatively you can add a class name to the link:

<div id="mydiv"> 
    <%= Html.ActionLink("Some Text", "SomeAction", 
            new { @class = "class-name" }) %> 
</div> 

Comments

9

Maybe

<%=Html.ActionLink("Text","Act","Ctrl",new {@style="color:white;"}) %>

Comments

5

Mine is like Luke's but I have a null in there (I'm using MVC2)

<%=Html.ActionLink("Text","Act","Ctrl",new {@style="color:white;"}) %>

Comments

5

In my case this one worked

HTML.ActionLink("LinkLabel", "ActionName", "Controller", null, 
               new {@class="btn btn-primary pull-right"})

If I don't use null above the proper controller action i.e. Controller.ActionName method was not called. Instead something like currentController/Length==4 something like this was called.

Comments

2

Try removing the :link and just having

#mydiv a { color:white}

this should colour the link white.

I'd recommend using the Firebug plugin for firefox also, this allows you to change the stylesheet and see instant changes as well as see which styles are being applied to each element, which styles are being 'overuled' by other styles etc.

Comments

1

Try:

#mydiv a { color:white}

Also, try remove the whitespace around your Id attribute (just in case): ->

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.