I am trying to write a style using Html.Raw
in an ASP.NET MVC view but it is not working. If I check page source, then that particular style is not there in HTML source in <head>
.
I have tried the following methods:
<style>
@{
Html.Raw("table.dataTable tbody td { white-space: nowrap; }");
}
</style>
and
@{
Html.Raw("<style> table.dataTable tbody td { white-space: nowrap; } </style>");
}
I also tried Html.Display
but same issue. How can I display style like this?
I am trying to write a style using Html.Raw
in an ASP.NET MVC view but it is not working. If I check page source, then that particular style is not there in HTML source in <head>
.
I have tried the following methods:
<style>
@{
Html.Raw("table.dataTable tbody td { white-space: nowrap; }");
}
</style>
and
@{
Html.Raw("<style> table.dataTable tbody td { white-space: nowrap; } </style>");
}
I also tried Html.Display
but same issue. How can I display style like this?
You can define div tag and apply style in it. In the @Html.Raw
tag , no need of @{}
to render the tag.
Html.Raw
returnsIHtmlString
, an interface which can be used to write the content into the response. But you've then ignored the return value. – Jeremy Lakeman Commented Jan 21 at 1:56