Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > CSS question

Reply
Thread Tools

CSS question

 
 
NWx
Guest
Posts: n/a
 
      02-19-2004
Hi,

Can someone explain me how can I set a CSS for a hyperlink?

I have the following definitions in .css file

/* definition 1*/
A.HWHeaderLink:hover

{

font-weight: bold;

font-size: 11px;

color: yellow;

font-family: Verdana;

background-color: #6699ff;

}

/* definition 2*/
A.HWHeaderLink:visited, A.HWHeaderLink:active, A.HWHeaderLink:link

{

font-weight: normal;

font-size: 11px;

color: yellow;

font-family: Verdana;

background-color: #0000cc;

}

And I have a hyperlink with cssclass="HWHeaderLink"

If I let those both CSS sections in CSS file , the link always looks as
defined in Definition 2, even if I move mouse over it

If I want the activate the hover effect, I have to remove definition 2, but
in this case hyperlink uses defaults for the page in all cases except hover
case. How should my CSS definitions looks, to be able to define its aspect
in all situations (hover, active, link and visited), and of course, to have
them different.

Thank you


 
Reply With Quote
 
 
 
 
Fadi El-Eter
Guest
Posts: n/a
 
      02-19-2004
Your definition 2 can be like this to solve the problem:
A.HWHeaderLink {
font-weight: normal;
font-size: 11px;
color: yellow;
font-family: Verdana;
background-color: #0000cc;
}

try it.

--
Fadi El-Eter, itoctopus - http://www.itoctopus.com
"NWx" <> wrote in message
news:eTNn8#...
> Hi,
>
> Can someone explain me how can I set a CSS for a hyperlink?
>
> I have the following definitions in .css file
>
> /* definition 1*/
> A.HWHeaderLink:hover
>
> {
>
> font-weight: bold;
>
> font-size: 11px;
>
> color: yellow;
>
> font-family: Verdana;
>
> background-color: #6699ff;
>
> }
>
> /* definition 2*/
> A.HWHeaderLink:visited, A.HWHeaderLink:active, A.HWHeaderLink:link
>
> {
>
> font-weight: normal;
>
> font-size: 11px;
>
> color: yellow;
>
> font-family: Verdana;
>
> background-color: #0000cc;
>
> }
>
> And I have a hyperlink with cssclass="HWHeaderLink"
>
> If I let those both CSS sections in CSS file , the link always looks as
> defined in Definition 2, even if I move mouse over it
>
> If I want the activate the hover effect, I have to remove definition 2,

but
> in this case hyperlink uses defaults for the page in all cases except

hover
> case. How should my CSS definitions looks, to be able to define its aspect
> in all situations (hover, active, link and visited), and of course, to

have
> them different.
>
> Thank you
>
>



 
Reply With Quote
 
 
 
 
Jon
Guest
Posts: n/a
 
      02-19-2004
Hi,
you have to define link styles in this order Link - Visited - Hover -
Active. Reason is in CSS the style closest to the elements always wins, so
if you had for example
a:hover{
color:red;
}
a:visited{
color:blue;
}
When you hover over a visited link both of those styles could apply (the
link is visited and being hovered over) but because visited is closest to
the element it wins - result the hover colour will never show on visited
links. But if you did it like this
a:visited{
color:blue;
}
a:hover{
color:red;
}
the hover style will show correctly.

Jon

"NWx" <> wrote in message
news:eTNn8%...
> Hi,
>
> Can someone explain me how can I set a CSS for a hyperlink?
>
> I have the following definitions in .css file
>
> /* definition 1*/
> A.HWHeaderLink:hover
>
> {
>
> font-weight: bold;
>
> font-size: 11px;
>
> color: yellow;
>
> font-family: Verdana;
>
> background-color: #6699ff;
>
> }
>
> /* definition 2*/
> A.HWHeaderLink:visited, A.HWHeaderLink:active, A.HWHeaderLink:link
>
> {
>
> font-weight: normal;
>
> font-size: 11px;
>
> color: yellow;
>
> font-family: Verdana;
>
> background-color: #0000cc;
>
> }
>
> And I have a hyperlink with cssclass="HWHeaderLink"
>
> If I let those both CSS sections in CSS file , the link always looks as
> defined in Definition 2, even if I move mouse over it
>
> If I want the activate the hover effect, I have to remove definition 2,

but
> in this case hyperlink uses defaults for the page in all cases except

hover
> case. How should my CSS definitions looks, to be able to define its aspect
> in all situations (hover, active, link and visited), and of course, to

have
> them different.
>
> Thank you
>
>



 
Reply With Quote
 
PeterMcC
Guest
Posts: n/a
 
      02-19-2004
NWx <> wrote in
<eTNn8%>

> Hi,
>
> Can someone explain me how can I set a CSS for a hyperlink?
>
> I have the following definitions in .css file
>
> /* definition 1*/
> A.HWHeaderLink:hover
>
> {
>
> font-weight: bold;
>
> font-size: 11px;
>
> color: yellow;
>
> font-family: Verdana;
>
> background-color: #6699ff;
>
> }
>
> /* definition 2*/
> A.HWHeaderLink:visited, A.HWHeaderLink:active, A.HWHeaderLink:link
>
> {
>
> font-weight: normal;
>
> font-size: 11px;
>
> color: yellow;
>
> font-family: Verdana;
>
> background-color: #0000cc;
>
> }
>
> And I have a hyperlink with cssclass="HWHeaderLink"
>
> If I let those both CSS sections in CSS file , the link always looks
> as defined in Definition 2, even if I move mouse over it
>
> If I want the activate the hover effect, I have to remove definition
> 2, but in this case hyperlink uses defaults for the page in all cases>

define its aspect in all situations (hover, active, link and
> visited), and of course, to have them different.


> except hover case. How should my CSS definitions looks, to be able to



Links should be defined in the order: link, visited, hover, active -
otherwise, when the link fulfils two of the definitions, e.g. a visited link
over which you are hovering, the latter definition takes precedence - the
way you have them the hover is defined first and so will be over-ridden by
other applicable definitions.

I'd also caution against changing font weight in the hover - it can make the
page twitch as the hover text enlarges, pushes the other elements to make
room for itself and then contracts to normal weight when the mouse moves on.

And, since I've started down the "whilst I'm about it" route, Verdana is not
a good choice since, if the user doesn't have it installed, the fall-back
font (often Arial) is likely to be significantly harder to read than the
Verdana. Text which is legible when viewed in Verdana can become too small
to read in Arial. Compare the 10px Verdana with the 10px Arial at
http://www.virtuelvis.com/archives/146.html

The Verdana problem is exacerbated by the use of px - IE users will not be
able to resize the text to suit their own browser needs and 11px Arial is
likely to be quite hard for a lot of folks to read. I'd recommend using % or
em for font sizes so that they can be adjusted to fit the needs of the
visitor.


--
PeterMcC
If you feel that any of the above is incorrect,
inappropriate or offensive in any way,
please ignore it and accept my apologies.

 
Reply With Quote
 
NWx
Guest
Posts: n/a
 
      02-19-2004
Hi,

Thank you all for your answers.

Regards



"NWx" <> wrote in message
news:eTNn8%...
> Hi,
>
> Can someone explain me how can I set a CSS for a hyperlink?
>
> I have the following definitions in .css file
>
> /* definition 1*/
> A.HWHeaderLink:hover
>
> {
>
> font-weight: bold;
>
> font-size: 11px;
>
> color: yellow;
>
> font-family: Verdana;
>
> background-color: #6699ff;
>
> }
>
> /* definition 2*/
> A.HWHeaderLink:visited, A.HWHeaderLink:active, A.HWHeaderLink:link
>
> {
>
> font-weight: normal;
>
> font-size: 11px;
>
> color: yellow;
>
> font-family: Verdana;
>
> background-color: #0000cc;
>
> }
>
> And I have a hyperlink with cssclass="HWHeaderLink"
>
> If I let those both CSS sections in CSS file , the link always looks as
> defined in Definition 2, even if I move mouse over it
>
> If I want the activate the hover effect, I have to remove definition 2,

but
> in this case hyperlink uses defaults for the page in all cases except

hover
> case. How should my CSS definitions looks, to be able to define its aspect
> in all situations (hover, active, link and visited), and of course, to

have
> them different.
>
> Thank you
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: correction: A question about css (was: A question about css) richard HTML 12 03-09-2010 08:52 PM
Is this the newsgroup for CSS help? CSS Question Included AF HTML 17 08-09-2006 06:57 PM
CSS question - can I make CSS Cascade sideways? Bill_W_Stephens@yahoo.com HTML 6 03-18-2006 06:02 PM
CSS Layout question - how to duplicate a table layout with CSS Eric ASP .Net 4 12-24-2004 04:54 PM
print.css and screen.css tom watson HTML 1 09-09-2003 02:48 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57