• 0

Question

I have an ID called 'self' that makes the link of the current viewing page bold and a different color. But i use this twice, so it probably should be a class. But when I make it a class, it makes the link bold, but does not change the color. Am i doing somehting wrong? or should i just make it 2 classes. Its just going to be used twice for my header and footer. I could create 2 IDs for head and foot, but I want to try to work this out. Thanks

HTML:


<ul>
<li><a href="index.html" id="self">Home</a></li>
...
...
...
</ul>
[/CODE]

CSS:

[CODE]
.self {
color: #996633;
font-weight: bold;
}
[/CODE]

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

In your example your link is an id but your css a class?


<ul>
<li><a href="index.html" class="self">Home</a></li>
.........
</ul>
[/CODE]

[CODE]
a.self{
color:#996633;
font-weight:bold;
}
[/CODE]

That should work as the css targets the anchor tag with a class of self.

Link to comment
Share on other sites

  • 0

@the better twin, it still does not work. I mean it makes it bold, but does not change color. Does same as if i left it as .self{}.

In your css, try the following (just in case the link has been clicked already and is in a visited state):


a.self:visited {
color:#996633;
font-weight:bold;
}
[/CODE]

EDIT: Nevermind, I just noticed that you mentioned that it does bold the text. Sorry about that.

Link to comment
Share on other sites

  • 0

Change to the following:

HTML:


<ul>
<li><a href="index.html" class="self">Home</a></li>
...
</ul>
[/CODE]

CSS:

[CODE]
li a.self {
color: #996633;
font-weight: bold;
}
[/CODE]

Edited by geeman89
Link to comment
Share on other sites

  • 0

Change to the following:

HTML:


<ul>
<li><a href="index.html" class="self">Home</a></li>
...
</ul>
[/CODE]

CSS:

[CODE]
li.self {
color: #996633;
font-weight: bold;
}
[/CODE]

The following would work too right?:

[CODE]
li a.self {
color: #996633;
font-weight: bold;
}
[/CODE]

Link to comment
Share on other sites

  • 0

The following would work too right?:


li a.self {
color: #996633;
font-weight: bold;
}
[/CODE]

Right sorry. Left out the [font=courier new,courier,monospace]a[/font].

Link to comment
Share on other sites

  • 0

I think i'm jus gonna add style to the html. Since i'm only using this twice.

HTML:


<ul>
<li><a href="index.html" style="color: #996633; font-weight: bold;">Home</a></li>

...
...
...
</ul>
[/CODE]

Link to comment
Share on other sites

  • 0

I think i'm jus gonna add style to the html. Since i'm only using this twice.

HTML:


<ul>
<li><a href="index.html" style="color: #996633; font-weight: bold;">Home</a></li>

...
...
...
</ul>
[/CODE]

Honestly, I wouldn't recommend that because it makes it harder to read the code and it doesn't maintain the idea of seperating the content from the presentation. To each their own though! :)

Link to comment
Share on other sites

  • 0

a&lt;span class="kwd"&gt;&lt;span style="font-family: monospace;"&gt;.&lt;/span&gt;self&lt;/span&gt;:link, a.&lt;span class="kwd"&gt;self&lt;/span&gt;:visited, a.&lt;span class="kwd"&gt;self&lt;/span&gt;:hover, a.&lt;span class="kwd"&gt;self&lt;/span&gt;:active{some css}

lol, wow! :s

Link to comment
Share on other sites

This topic is now closed to further replies.