Having Different Link Colors on One Pageby: Ades TynyshevHaving different link colors on one page Do you want to have a different color links on different sections of your website? If your answer is yes then you have come to the right tutorial. Often websites have different color backgrounds on different sections of their website, for example content section of your website might have a white background, in contrast footer section might have a darker background color. Problem arises when you have links on the footer, default link-color is blue therefore it might not be very visible on the darker background. Luckily there is a way to solve this problem with CSS which we are going to do next.
You need to put the above code between <Head></Head> tags in your page's source code like this:
Now let's create a table with 2 rows and 1 column, set the first row background to yellow and second row background to dark gray. And create a sample links inside each row. (Just imagine that the second row with dark gray background is your footer section of the page). See Example As you see from the example, red link on yellow background is very visible, however the link on gray background is not-so-visible-and-readable. Our next task will be to create a seperate CSS style for the second link.
Add the red lines to your CSS, as shown above. Here we are declaring a new style that says "Make all the links in the table- cell called 'footer' to white".
Just add the code in red to the source code of your table (make sure you add the code to the right cell, notice that we are adding to the cell where Link 2 resides). We are done, view your page and voila the second link became white! See Example Second way of doing this Above we have applied the css style to the whole table cell, applying css to the table cell can save us time in converting all the links in that particular table cell to one color (in our example we have turned them to white). However I would like to show you the second way, applying to individual links separately one by one. This might be useful if you have only one link in the page to be different color than the rest.
As you see the structure of the style is pretty straightforward, a(dot)your link style name(colon)link state And this is how you apply the style to the link, just add class="linkStyleName" inside the link code as shown below:
Feel free to change the color of the link states (link, hover, visited, active). To keep the tutorial simple I used only one color for all four states. © 2008 NetVisits, Inc. All rights reserved. |