locked
Best way of applying styles to a hyperlink control RRS feed

  • Question

  • User1953081067 posted

    Hi

    Can anyone suggest the best way of applying CSS styles to a hyperlink control; specficlly:

    a:link, a:hover, a:active, etc.

    If I use a CSS sheet and then 'cssClass='myStyles', the CSS doesn't work (other than simply changing the colour), but if I wrap the hyperlink control in a DIV and assign the CSS class to the DIV, the styles for the above work fine.

    But wrapping the hyperlink control on a DIV this way just doesn't seem right somehow? Is there a better way?

    Many thanks as always
    Rich 

    Monday, December 27, 2010 4:39 PM

Answers

  • User1953081067 posted

    Solved it!

    ASP.NET:

    <asp:HyperLink ID="HyperLink_FAQ" runat="server" CssClass="MainHeaderLink" NavigateUrl="~/faq/Default.aspx" title="Review our frequently asked questions to answer some of the more common queries">FAQ</asp:HyperLink>



    CSS:

    a.MainHeaderLink, a.MainHeaderLink:link, a.MainHeaderLink:active, a.MainHeaderLink:visited
    {
        font-size: 1.2em;
        color: #0c3461;
        font-weight: bold;
    }
    
    a.MainHeaderLink:hover
    {
    	text-decoration: none;
    	outline: none;
    	color: #e4810d; /* Orange */
    }



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 27, 2010 5:05 PM