Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Greetings,
i have a question regarding CSS. Here's what one of my sheets looks like:
====================
a:link{text-decoration:none; color:#0000ff; font-weight:bold;}
a:visited{text-decoration:none; color:#0000ff; font-weight:bold;}
a:hover{text-decoration:none; color:#00ff00; font-weight:bold;}p.pic
{
position:absolute;
left:275px;
top:104px;
}p.message
{
a:link{text-decoration:none; color:#0000ff; font-weight:normal;}
a:visited{text-decoration:none; color:#0000ff; font-weight:normal;}
a:hover{text-decoration:none; color:#00ff00; font-weight:normal;}
position:absolute;
top:475px;
}
============================i want the hyperlinks in "p.message" to display as normal text, NOT BOLDED like the hyperlinks in "p.pic" appear. What do i need to alter in this code to make this happen?
i would like keep this all within one style sheet.Thanks for your time,
Nick

a:link{text-decoration:none; color:#0000ff; font-weight:normal;}
why are you puttin
;
before the closing bracket, it is not needed, however i dont think this will solve your porblem, may wanna try it though...
i think the way you have got it set out,
a:link{text-decoration:none; color:#0000ff; font-weight:bold;}
a:visited{text-decoration:none; color:#0000ff; font-weight:bold;}
a:hover{text-decoration:none; color:#00ff00; font-weight:bold;}is overiding p.message
Sign Me Guestbook!
jaymc.co.nr

If you look at the syntax rules for CSS (and you wondered when you would ever use all those grammar rules you learned in college...), you will see that what you're trying to do is nested rulesets...This isn't allowed. The only thing allowed in declaration blocks are declarations...not more declaration blocks.
I don't know if parsers even know what an element's "parent" is, although I suppose it's possible that in the future they might allow something like what you're trying to do.
Also, the rules show that the ; before the } is perfectly legal CSS.
On to solving the problem...You'll have to have each Anchor have a class, ([A href="#" class='inmessage']) and give rules for them as A.inmessage:hover, A.inmessage:link, etc.
I know this is lame, and if anybody has a better solution I'm all ears. You may be stuck with this though.
-SN

yeh thats what i was thinkin, take a lot of messin round though, unlucky mate
about that ;} bit
yeh its allowed, but why do it if its not needed? lol, mind u every 1 has their own ways
Sign Me Guestbook!
jaymc.co.nr

I think
"p.message
{
a:link{text-decoration:none; color:#0000ff; font-weight:normal;}
a:visited{text-decoration:none; color:#0000ff; font-weight:normal;}
a:hover{text-decoration:none; color:#00ff00; font-weight:normal;}
position:absolute;
top:475px;
}"could be better written as
"p.message
{
position:absolute;
top:475px;
}p.message a:link
{
text-decoration:none; color:#0000ff; font-weight:normal;
}p.message a:visited
{
text-decoration:none; color:#0000ff; font-weight:normal;
}p.message a:hover
{
text-decoration:none; color:#00ff00; font-weight:normal;
}"'eyyyyyyyyyy

Exactly right pcweirdo, that is the correct way, so you are declaring the context for the non-bolded link. I suggest you also declare a context of BODY for the default link style, this will establish the start point for the hierarchy of inheritance for the link element.
Jamie, if you test CSS against W3C standards, it expects to see the semi-colon. Without may work, but it is not valid coding. :)

Thank you all very much for your thoughts on this question. I successfully implemented the css at hand with SN's and Pcweirdo's suggestions and things appear to work fine. Once again, thanks to everyone for their help.
Nick

pcweirdo's way is much better...I should have read the next page on CSS syntax rules...Descendant selectors.
All of the CSS examples on w3.org's site omit the last semicolon on the CSS rules...So it's pretty hypocritical of them to not allow it in their validators :-)
-SN

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |