Marijn Marijn - 1 year ago 53
ASP.NET (C#) Question

ASP.NET Css will not work

Im trying too get CSS too work on my page but I can't fix this. Can some one take a look at my code and help me?

This is the place where I want my css.
Css pagename is StyleSheet.css

@model IEnumerable<DNDB.Models.Domeinnaam>

<head> @Styles.Render("~/Content/StyleSheet.css") </head>
ViewBag.Title = "Index";
<h2>Domeinnaam Overzicht</h2>

@Html.ActionLink("Voeg toe", "Create")
<table class="tabledomeinnamen">
@Html.DisplayNameFor(model => model.IsActief)

This is my _layout page:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<title>@ViewBag.Title - My ASP.NET MVC Application</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />


#body {
width: 100%;
background-color: red;

#tabledomeinnamen {
margin: 0 auto;
width: 60%;
color: white;
background-color: red;

#tabledomeinnamen td {
padding-left: 10px;
padding-right: 10px;
border: 1px solid white;
background-color: forestgreen;
#Banner {
width: 75%;
margin: 0 auto;
text-align: center;


#Footer {
width :75%;
margin :0 auto;
color :black;
clear :both;
text-align :center;
padding-left: 25px;
padding-right: 25px;
#menu {
text-align: center;

Can some one tell me or explain me how I should fix this?

EDIT: I'm kinda new to programming so this isn't easy for me.

Answer Source

Your CSS is wrong, you are using an ID selector instead of a class selector. The hash (#) means that you call to a ID within your HTML. But if you look at your HTML you only have a class defined on the table. To select elements with a specific class, write a period (.) character, followed by the name of the class in your CSS.

More information about ID's and classes can be found here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download