Oliver
Oliver

Reputation: 23550

CSS - Cannot override P.class because of * definition

I have a site using 2 css : one global, one page specific.
By default, I want to set a font type and size for everything, and adjust it depending on my needs on some pages.

So I have :

global.css

* {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}

html {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    margin: 0px;
}

p {
    text-align:justify;
    margin:0px;
    margin-bottom:10px;
}

a:link {
    color: #993300;
    text-decoration: none;
}

a:visited {
    color:#993300;
    text-decoration: none;
}

a:hover {
    color: #FF0000;
    text-decoration: underline overline;
}

news.css

div.news{
    width: 100%;
}

.news p.reminder {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #848484;
    margin:0px;
    margin-bottom:20px;
    text-align: center;
    position: relative;
    top: -10px;
    text-transform: uppercase;
}
.news p.reminder a:link, .news p.reminder a:visited {
    color: #848484;
}
.news p.reminder a:hover {
}

HTML file

       <HTML>
          <HEAD>
             <TITLE>the title</TITLE>

              <LINK href="global.css" rel="stylesheet" type="text/css">
              <LINK href="news.css" rel="stylesheet" type="text/css">
           </HEAD>
           <BODY>
              <DIV class="news"> 
                    <P class="reminder"> 
                        <A href="some_url">some text</A> 
                    </P>
                </DIV>
            </BODY>
        </HTML>

For a reason I don't see, the part :

.news p.reminder {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;

is not taken into account.
If I remove the * definition from the global.css, it's OK. But if I keep it, that part does not override it.

How may I do to make this work ?

Upvotes: 2

Views: 3033

Answers (1)

Quentin
Quentin

Reputation: 944171

The reason you don't see it is because, while the paragraph does take on the styles you want, the * selector matches <A href="some_url"> and promptly changes them back.

You could modify the selector to match the a element too, but I'd set the font styling on the body instead of *

Upvotes: 6

Related Questions