Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Text decoration not working

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #183542
    Everton
    Participant

    Hello

    I have this in the <head> tags of the Site.master file in a ASP.NET project:

    <style type="text/css">
    
    .nav a:link { color: #ffffff; text-decoration: none; }
    .nav a:hover { color: #ffffff; text-decoration: underline; }
            
    </style>

    Between the <body> tags I have this:

     <AnonymousTemplate>
            <ul class="nav navbar-nav navbar-right">
    
     <li><a runat="server" href="~/Account/Register">Register</a></li>
      <li><a runat="server" href="~/Account/Login">Log in</a></li>
    
                                    </ul>
                            </AnonymousTemplate>

    When I preview my project – I have cleared the browser cache – the two links, Register and Log in, are unaffected.

    Is my script correct, please, and if it is why wouldn’t the browser respond to the styling I have given my Web page?

    I can’t put this online because ASP.NET projects are compiled and the CSS files are not visible.

    Thanks!

    #183547
    Anonymous
    Inactive

    Try adding !important after text-decoration value

    .nav a:link { color: #ffffff; text-decoration: none !important; }
    .nav a:hover { color: #ffffff; text-decoration: underline !important; }

    I noticed that you are applying text-decoration to unvisited links. If you haven’t visited that link, the style wont apply. So click on it and see what happens.

    :link pseudo styles links that haven’t been clicked.

    #183548
    Everton
    Participant

    I have copied and pasted that in my Master file and then in my Register.aspx file but it doesn’t change anything.

    #183549
    Everton
    Participant

    I have asked on the Microsoft ASP.NET forum and a couple of moderators there have said the issue is CSS related?!

    #183550
    __
    Participant

    I can’t put this online because ASP.NET projects are compiled and the CSS files are not visible.

    If you can look at the results in a browser, you can look at the generated CSS.

    The best approach is to make a reduced test case, e.g., on codepen. Find the minimum amount of code that demonstrates your problem.

    The code you posted does this.

    #183551
    Everton
    Participant

    I have a test site here

    Your text to link here…

    so I know it works. Just can’t get it to work in Visual Studio.

    Yes, I can run Inspector in IE and post back, if that’s OK?

    #183552
    __
    Participant

    Is the result any different in IE? I’m looking at your test site in FireFox, and it displays exactly as expected. What do you expect it to look like?

    I know it works. Just can’t get it to work in Visual Studio.

    To clarify, are you having problems in a browser or only in Visual Studio?

    In the former case, I’ll be happy to help you investigate further.

    In the latter case, I say it’s not a problem. Just a reminder that you should use a real browser for development, and not some pricey piece of software that pretends to be one. No one will ever use Visual Studio to visit your finished website.

    #183553
    Everton
    Participant

    I expect the two links to be in white and when I hover the mouse over, I expect them to be underlined.

    It doesn’t work via IE or Safari.

    Not sure what you mean by this: ‘use a real browser for development, and not some pricey piece of software that pretends to be one’.

    ‘No one will ever use Visual Studio to visit your finished website’.

    Not sure what you mean, sorry.

    Enjoy your evening.

    #183555
    __
    Participant

    Not sure what you mean by this: ‘use a real browser for development, and not some pricey piece of software that pretends to be one’.

    After reading your earlier post, I wasn’t sure if you were describing a problem you saw in a browser or in Visual Studio. I was pointing out that one of those situations matters, and the other doesn’t really. But you say it’s an IE + Safari problem, so this distinction is not strictly relevant.

    I expect the two links to be in white and when I hover the mouse over, I expect them to be underlined.

    This is what I see (in Firefox, chrome, and IE11), though note (as @htmlcinco mentioned) that links you have already visited will not necessarily be white, since the default for :visited links in most browsers is a purplish color.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘CSS’ is closed to new topics and replies.