Add CSS class to Html.ActionLink
-
07-06-2021 - |
Question
I want to style a link in my page and am using Html.ActionLink to create the link. The problem is I don't know how to style the resulting link. How do I add a CSS class to the Html.ActionLink in order to style it?
Solution
Html.ActionLink("Link Name",
"ActionName",
"ControllerName",
null,
new { @class = "myCssClass" }
)
OTHER TIPS
@Html.ActionLink("Forgot Password ?", "ViewName","ControlerName",null, new { @class="Link"})
Add Link class is <head>
tag
<style type="text/css">
.Link
{
margin-bottom:20px;
color:blue;
font-weight:bold;
}
</style>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow