0

CSS isn't being applied in aspx page. It works when the css is defined in the same page (href references a.classname) but when it is put into a stylesheet it is not applied. When element is inspected, Chrome says user agent stylesheet is being applied.

It says that a:-webkit-any-link is being applied to hyperlinks (user agent stylesheet)

Any ideas why this isn't working?

I reference the class for the hyperlink using:

<div class="summaryitem"><a ID="hl" runat="server" href="" class="someclassname">Hyperlink CSS should be applied to this</a>

Here's the CSS I'm using:

a.someclassname:link { 
    font-weight: bold;   
    color: #555;
    text-decoration:none;
    }
a.someclassname:visited { 
    font-weight: bold;   
    color: #555;
    text-decoration:none;
    }
a.someclassname:hover { 
    font-weight: bold;   
    color: #555;
    text-decoration:none;
    }
a.someclassname:active { 
    font-weight: bold;   
    color: #555;
    text-decoration:none;
    }
4
  • 1
    could you show us your code where you reference the stylesheet document? maybe the path is incorrectly specified? relative versus absolute is what i'm thinking at the moment... Commented Sep 26, 2011 at 9:14
  • The path is correct as other elements in the page use css from the same stylesheet. Commented Sep 26, 2011 at 9:26
  • It says that a:-webkit-any-link is being applied to hyperlinks (user agent stylesheet) Commented Sep 26, 2011 at 9:26
  • I've updated my question with more details Commented Sep 26, 2011 at 9:32

3 Answers 3

2

I think you have not properly added your stylesheet, does it resemble something like this

<link type="text/css" href="css/mylayout.css" rel="Stylesheet" />
Sign up to request clarification or add additional context in comments.

1 Comment

It is added in that way. But it seems to still not be applied
2

Please check the following

  1. Check the href location that you are refering is correct.
  2. Try to delete the offline files in your browser
  3. Check your class name correctly mapped..

Comments

1

If you're in a partial view, just be sure the parent view includes the CSS ref.

EDIT: wow got a similar problem a few minutes ago. I've solved testing my view with Chrome and using the network auditing feature (at the page hit F12, click on Network and then reload your page). Should tell you at least if your CSS is correctly sent to the browser. (my problem was I wasn't referencing the correct CSS).

EDIT-2: I usually refer to CSS via:

<link href="@Url.Content("~/Content/css/fg.menu.css")" media="screen" rel="stylesheet" type="text/css" />

But I'm using MVC with Razor views, I've noticed that putting CSS out of the Content folder can be nasty on ASP.NET.

HTH

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.