ASP.net Style affects all links

Hi

In my ASP.net project I have the following markup. It was intended to be used only for my horizontal menu
but affects every link on the website. Is there a way to get around this? Thanks

<style>
  ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

li {
    float: left;
}

a:link, a:visited {
    display: block;
    width: 120px;
    font-weight: bold;
    color:white;
    background: linear-gradient(to bottom, lightskyblue,navy);
    text-align: center;
    padding: 10px;
    text-decoration: none;
    text-transform: uppercase;
    font-family:'Arial Rounded MT'
}

a:hover, a:active {
    background: linear-gradient(to bottom, lightskyblue,black);
    text-align: center;
}
#grad1  {
                color:blue;
                background: linear-gradient(to bottom, lightskyblue,navy);
                padding: 20px
           }
#grad2  {
                color:blue;
                background: linear-gradient(to bottom, lightskyblue,navy);
           }
</style>
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
a:link, a:visited {
    display: block;
    width: 120px;
    font-weight: bold;
    color:white;
    background: linear-gradient(to bottom, lightskyblue,navy);
    text-align: center;
    padding: 10px;
    text-decoration: none;
    text-transform: uppercase;
    font-family:'Arial Rounded MT'
}

a:hover, a:active {
    background: linear-gradient(to bottom, lightskyblue,black);
    text-align: center;
}

Use a class name instead.  Then apply that class to the links in your menu.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Russ SuterCommented:
Yes, you can limit the style so it only affects elements within other elements or where elements have certain classes. Here's an example:

ul > li > a
{
    font-weight: bold;
    color: blue;
}

ul.ugly > li > a
{
    color: yellow;
    background-color: red;
}

Open in new window

In the above example the first style will only be applied to <a> elements if they are inside a <li> element which is, in turn, inside a <ul> element.
The second example will only apply the style to the <a> element if it is inside a <li> element which is inside a <ul> element only where the <ul> element has a class name of "ugly"
You can also apply classes directly to elements.
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.