I'm a complete HTML/CSS novice and I am trying to get a .cshtml file to use some basic CSS I wrote. What code do I need to put in my .cshtml to get it to use the CSS file?
Edit: This is the code in my .css file. It is intended to style my div
with the id of "comment_box1", but even after following the answer, it's not working. Any idea what's wrong?
.comment_box1 {
background-color: #C8E0E8;
width: 830px;
height: 180px;
}
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;
}