473,439 Members | 5,047 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,439 software developers and data experts.

CSS and HTML links

Not sure if this is the right place for a CSS question but I saw some other
CSS posts so here goes a pretty basic question.

I want the color of an HTML link to be blue on one section of my HTML page
and green in another section of the same page.

I am familiar with CSS and I know that I can use the a:link property to set
one color for the _entire_ page.

But I am having problems setting the link color on specific links.

Is this possible? If so, could you give me a brief example on how to do this?

TIA
Nov 19 '05 #1
4 1367
Paul wrote:
But I am having problems setting the link color on specific links.


use an id for each link

--
Software is like sex: it's better when it's free -- [Linus Torvalds]

Fabio Marini - A+, RHCT, MCDBA, MCAD.NET
To reply: news [at] mamakin1976 [dot] plus [dot] com
Nov 19 '05 #2
I am not sure whether this is the right place to ask these questions,
either.

In your situation, your design will benefit from using CSS class rules to
identify links. For instance, if your code is as follows:

<div class="SectionOne"><a href="">Link 1</a><a href="">Link2</a></div>
<div class="SectionTwo"><a href="">Link 3</a><a href="">Link 4</a></div>

The CSS code to color links of the first section blue and links of the
second section green is as follows:

..SectionOne a { color: blue }
..SectionTwo a { color: green }

I would also highly recommend reading up on how CSS works in MSDN library:

http://msdn.microsoft.com/library/de...node_entry.asp

:DG<

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Not sure if this is the right place for a CSS question but I saw some
other
CSS posts so here goes a pretty basic question.

I want the color of an HTML link to be blue on one section of my HTML page
and green in another section of the same page.

I am familiar with CSS and I know that I can use the a:link property to
set
one color for the _entire_ page.

But I am having problems setting the link color on specific links.

Is this possible? If so, could you give me a brief example on how to do
this?

TIA

Nov 19 '05 #3
While these other answers will work, there's a much simpler way to do it.
Just use different classes. For example:

a:link.blue
{
color: blue;
}
a:link.green
{
color: green;
}

Then, for your links:

<a class="blue" href="URL">Text</a>
<a class="green" href="URL">Text</a>

"Dimitri Glazkov" wrote:
I am not sure whether this is the right place to ask these questions,
either.

In your situation, your design will benefit from using CSS class rules to
identify links. For instance, if your code is as follows:

<div class="SectionOne"><a href="">Link 1</a><a href="">Link2</a></div>
<div class="SectionTwo"><a href="">Link 3</a><a href="">Link 4</a></div>

The CSS code to color links of the first section blue and links of the
second section green is as follows:

..SectionOne a { color: blue }
..SectionTwo a { color: green }

I would also highly recommend reading up on how CSS works in MSDN library:

http://msdn.microsoft.com/library/de...node_entry.asp

:DG<

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Not sure if this is the right place for a CSS question but I saw some
other
CSS posts so here goes a pretty basic question.

I want the color of an HTML link to be blue on one section of my HTML page
and green in another section of the same page.

I am familiar with CSS and I know that I can use the a:link property to
set
one color for the _entire_ page.

But I am having problems setting the link color on specific links.

Is this possible? If so, could you give me a brief example on how to do
this?

TIA


Nov 19 '05 #4
Sorry, the CSS should have looked like this:

a.blue:link
{
color: blue;
}
a.green:link
{
color: green;
}

And where I have :link, you can do the same things with :hover, :active, and
:visited.

"Petie" wrote:
While these other answers will work, there's a much simpler way to do it.
Just use different classes. For example:

a:link.blue
{
color: blue;
}
a:link.green
{
color: green;
}

Then, for your links:

<a class="blue" href="URL">Text</a>
<a class="green" href="URL">Text</a>

"Dimitri Glazkov" wrote:
I am not sure whether this is the right place to ask these questions,
either.

In your situation, your design will benefit from using CSS class rules to
identify links. For instance, if your code is as follows:

<div class="SectionOne"><a href="">Link 1</a><a href="">Link2</a></div>
<div class="SectionTwo"><a href="">Link 3</a><a href="">Link 4</a></div>

The CSS code to color links of the first section blue and links of the
second section green is as follows:

..SectionOne a { color: blue }
..SectionTwo a { color: green }

I would also highly recommend reading up on how CSS works in MSDN library:

http://msdn.microsoft.com/library/de...node_entry.asp

:DG<

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Not sure if this is the right place for a CSS question but I saw some
other
CSS posts so here goes a pretty basic question.

I want the color of an HTML link to be blue on one section of my HTML page
and green in another section of the same page.

I am familiar with CSS and I know that I can use the a:link property to
set
one color for the _entire_ page.

But I am having problems setting the link color on specific links.

Is this possible? If so, could you give me a brief example on how to do
this?

TIA


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Markus Ernst | last post by:
Hello I have a regex problem, spent about 7 hours on this now, but I don't find the answer in the manual and googling, though I think this must have been discussed before. I try to simply...
14
by: Akseli Mäki | last post by:
Hi, Hopefully this is not too much offtopic. I'm working on a FAQ. I want to make two versions of it, plain text and HTML. I'm looking for a tool that will make a plain text doc out of the...
68
by: Steve | last post by:
Hi There, Prob a simple answer to this (I hope) but I can't quite work it out yet... I have this in a page: <map name="Map"> <area shape="rect" coords="43,68,52,77" href="map.html"...
10
by: Papa.Legba.666 | last post by:
There are many good HTML validators, not least, of course being w3c's. However, they only handle one page at a time. Is there a free web based served, or pc program, which will crawl my site...
6
by: vandalo | last post by:
Hi all I developed a service which can convert an office document (word, excel, powerpoint into HTML and save it on the file system To do this I use the "save as" functions of the office...
5
by: Alan Silver | last post by:
Hello, I'm not sure if this is a stupid question or not, so here goes. Suppose I want to achieve the very common design layout as shown here... http://www.kidsinaction.org.uk/floating.html This...
4
by: qwweeeit | last post by:
Hi all, I'm a newbie in JS, but I've used it to print html + additional informations: - list of links (also internals) both text (document.links.text) and href - title (document.title) - URL,...
2
beacon
by: beacon | last post by:
I'm having trouble with a personal web page that I'm designing for work. I'm not well versed in HTML and could use some assistance. Currently, when I open the browser, the table in the head at the...
0
by: Formula | last post by:
Hello everybody,because I am newbie in python two weeks only but I had programming in another languages but the python take my heart there's 3 kind of arrays Wow now I hate JAVA :) . I am working...
2
by: kristin09 | last post by:
Hi guys, I have a windows mobile application that has html pages generated on the fly (some pages have links in them). With the new browser MSIE 6.0 the links on the pages are not read as links....
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.