How can I change the colors of the hyperlink created by the helper function Html.ActionLink?
[additional detail] The colors will have to be different for each state of the hyperlink, i.e. active, selected, was already selected, etc.
Typically you would do something like this:
Html.ActionLink("My Link", "MyAction", null, new { @class = "my-class" })
And then use CSS to style my-class:
a.my-class { color: #333333 }
a.my-class:active { color: #666666 }
a.my-class:link { color: #999999 }
a.my-class:visited { color: #CCCCCC }
The ActionLink() method is overloaded. Some of those signatures allow for the passing of a parameter object htmlAttributes.
You can do something like this:
Html.ActionLink("foo", "bar","baz",
new { id = 1}, // Route args if needed; null if not.
new {@style="color:#000aaa;" }
);
Perhaps you have a CSS class already defined:
Html.ActionLink("foo", "bar","baz",
new { id = 1}, // Route args if needed; null if not.
new {@class="MyClass;" }
);
Some explainations base on @dahlbyk answer
When setting the style for several link states, there are some order rules:
More detailes can be found here