March 3, 2013

How to prevent "a" styling from applying to a link?

Question by Dustin L.

I am trying to create a banner for my site without using an image. However, that banner is also a link.

Is there a way for me to override the use of the “a” (link) CSS styling from my div?

Assume the CSS looks like this:

a:link, a:visited {
    color: #176093;
}

#logo {
    color: red;
    font-size: 48px;
}

In other words, I’d like the CSS definitions for #logo to override the definitions for links.

Answer by Kolink

Converting comments to answer:

Using this, you can specify styles within a given container:

#logo a {
    color: red;
    /* ... */
}

Answer by Starx

If you only want to apply your styles to the anchor within the div #logo, you have to use a selector like this:

#logo a { 
    color: red;
    font-size: 48px;
}

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!