473,382 Members | 1,657 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,382 software developers and data experts.

Can link active/hover be controlled through a STYLE attribute?

Is there any way that a STYLE attribute can be used to control the color of
hyperlinks.

We have a tabular output generator written in C#. Each column of the table
is defined by a column, and each column can have what is called a "styler".
The styler is evaluated once for each cell, for every row emitted.

The idea behind the styler is that it can dynamically make decisions on
colors to apply. For example a list of Actions could change the Text Color
of a row to Red if it was overdue.

This all works fine, but a standard STYLE="color: red" attribute does not
affect the color of a hyperlink, and sometimes the tabular output will
contain some hyperlink columns.

Can this be done, or is CSS the only option?


Jul 28 '06 #1
4 7306
news.internode.on.net wrote:
Is there any way that a STYLE attribute can be used to control the color of
hyperlinks.
<http://www.w3.org/TR/CSS21/>
<http://www.w3.org/TR/CSS21/selector.html#x32for :hover.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Jul 28 '06 #2
news.internode.on.net <ke**********@hotmail.comscripsit:
Is there any way that a STYLE attribute can be used to control the
color of hyperlinks.
Not the way you want. Note that your Subject line contains a question that
you don't actually ask in the message content. The style="..." attribute,
when set for an <aelement, may affect the link, but you cannot distinguish
between active, hover, etc. states that way - you need a <styleelement or
an external style sheet.
We have a tabular output generator written in C#. Each column of the
table is defined by a column, and each column can have what is called
a "styler". The styler is evaluated once for each cell, for every row
emitted.
Make the generator emit class="..." attributes and use classes in CSS.
However, consider first the principle "don't mess around with link colors;
they are as they are for a reason". (See
http://www.cs.tut.fi/~jkorpela/www/links.html for a detailed explanation.)
This all works fine, but a standard STYLE="color: red" attribute does
not affect the color of a hyperlink, and sometimes the tabular output
will contain some hyperlink columns.
If you set the color of a cell, that won't affect the colors of the elements
inside the cell unless they inherit the color from the enclosing element.
And links won't, since they have their colors set in the browser style sheet
(at least). To set link color, you would have to set color for the <a>
element (or for a pseudo-element like :link that matches a <aelement in
one of its states).
Can this be done, or is CSS the only option?
You _are_ trying to use CSS, just the wrong way. The content of the
style="..." attribute is CSS.

If problems remain, I'd suggest asking for further clarifications in
c.i.w.a.stylesheets, the CSS group, and including the URL of a demo page to
illustrate what you are really doing.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jul 28 '06 #3

news.internode.on.net wrote:
Is there any way that a STYLE attribute can be used to control the color of
hyperlinks.
No. The style attribute has an implict selector of the element it's
applied to, not a sub-selection according to the :hover
pseudo-selector. You can set the link colours, but not the :focus /
:hover / :active conditions.

If you want to do this, you need to use a stylesheet (internal or
external) and appropriate selectors. This is easy if you have access
to the <headof the HTML document, but not validly if you can only
modify the body (e.g. postings to blogs etc.). However you can embded
a <styleelement inside a HTML body. It's not valid HTML, but it seems
to work with the browsers I tested it on (I did this live on the MSN
site for a couple of years)

If you want a valid-HTML tweak for :hover done entirely through the
element itself, look at using JavaScript.

Jul 28 '06 #4
news.internode.on.net wrote:
Is there any way that a STYLE attribute can be used to control the color of
hyperlinks.

We have a tabular output generator written in C#. Each column of the table
is defined by a column, and each column can have what is called a "styler".
The styler is evaluated once for each cell, for every row emitted.

The idea behind the styler is that it can dynamically make decisions on
colors to apply. For example a list of Actions could change the Text Color
of a row to Red if it was overdue.

This all works fine, but a standard STYLE="color: red" attribute does not
affect the color of a hyperlink, and sometimes the tabular output will
contain some hyperlink columns.

Can this be done, or is CSS the only option?
There is a 2002 CSS 3 Working Draft regarding the STYLE attribute
allowing the setting of properties on a source anchor for each of its
dynamic states using pseudo-classes at:
<http://www.w3.org/TR/css-style-attr>
however, I believe that there is no browser to date which supports it.

--
Gus
Jul 28 '06 #5

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

Similar topics

3
by: Matt Adams | last post by:
As well known I could specify the text color in the body tag like: <BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE> What I want to achieve now is that always (!) the text of the last visited...
7
by: LRW | last post by:
Below I'll paste my CSS and the HTML in question. But what's happening is, I'm trying to establish a link behavior for a class that's separate from the normal link class. I've established a: 's...
2
by: deko | last post by:
I use variables in some links on my page. I need to send these variables so I can change the color of the links in the navbar when the user is on that page. If you click around on the site you...
12
by: jfburr | last post by:
very simple thing (I hope) I've got a css style sheet that starts like this: ______________ A:link { color: cc9933; }
0
by: Andrea | last post by:
Hi everyone. I'm working on a navigation menu (in a frameset) that I want to set the "active" link to black (the link that corresponds to the page displayed in the right side of the frame) to...
7
by: Jamie | last post by:
Hi everyone, Meyer on p. 91 of "Eric Meyer on CSS" says that link styles must be added in LVHA order (link, visited, hover, active) or link styles will stop working. Why is that? Is there an...
2
by: Kevin Lyons | last post by:
Hello, Can anyone assist me with what I am trying to do with the following code (six different scenarios to try to make the functionality work correctly)? I want to always (and ONLY) display...
6
by: JimO | last post by:
Is there any way to reset a link's state. In other words reset a visited link to an unvisited link. I guess the question I'm asking would be how do you programatically search and clear the...
14
by: Daniel Kaplan | last post by:
So my style sheet has many different types of LINK styles. And they all work fine on IE, even different styles on the same page. But in Firefox, all link throughout my site all follow JUST the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.