I am new to ASP.NET MVCs. I want to ask if there is a way to add CSS inside your view, but not using an external .css file? For example: table {border: 5px solid red;}
(Just like you would do it in a normal HTML-CSS project)?
Consider using sections. In your layout add:
<head>
...
@RenderSection("Styles", required: false)
</head>
Then, in your view:
@section Styles
{
<style type="text/css">
table { border: 5px solid red; }
</style>
}
This will have the effect of adding this style tag into the head
of your HTML where it should be, instead of littering style
tags throughout your code.
You can also define
CSS
inrazor
view by using style tag as shown below:
<style>
table {border: 5px solid red;}
</style>
Hope this helps...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With