By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a

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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.