How to add a .css to a .cshtml
dotnet core
First, make sure you have wwwroot
folder and put your css
file inside it.
Second, check if you have app.UseStaticFiles();
in you startup.cs
Configure
method
Third, link to your files using a path like this ~/style.css
based on the path from wwwroot
Reference
You could also make the use of while using CSS in .cshtml files. In this case, paste the following code directly into your .cshtml file:
<style>
#comment_box1
{
background-color: #C8E0E8;
width: 830px;
height: 180px;
}
</style>
Here is the basic option - you add a style tag to the <head>
of your document...
<link rel="stylesheet" href="app.css" type="text/css" />
If you are using bundles, you place the bundle there instead:
@Styles.Render("~/Content/css")
And finally, if you are using a master layout, that's the best place to put this as it will then apply to all your pages.
Update
If you are targeting an id, you use #
, rather than the dot, which is for a class.
#comment_box1
{
background-color: #C8E0E8;
width: 830px;
height: 180px;
}