turbocueca Posted April 4, 2006 Share Posted April 4, 2006 I want to know if it is possible to have two or more a:link on the css styles, 'cause I want to make two different colors for the links of my website. Quote Link to comment https://forums.phpfreaks.com/topic/6606-having-more-than-one-alink/ Share on other sites More sharing options...
moberemk Posted April 4, 2006 Share Posted April 4, 2006 It is, if you use a descending selector. Just use the parent element, (#element, .element) and then put in a:whatever. Like this: #element a:whatever. Quote Link to comment https://forums.phpfreaks.com/topic/6606-having-more-than-one-alink/#findComment-24016 Share on other sites More sharing options...
turbocueca Posted April 5, 2006 Author Share Posted April 5, 2006 where am I supposed to put that?What's that #? Quote Link to comment https://forums.phpfreaks.com/topic/6606-having-more-than-one-alink/#findComment-24129 Share on other sites More sharing options...
wildteen88 Posted April 5, 2006 Share Posted April 5, 2006 With CSS there three selectors class (.), id (#) and html tag name (body, html etc)Now what moberemk meant was to give your anchor tag the id of elementname like so:[code]<a href="home.html" id="navlink">Home</a>[/code]Now to style any anchor tag with the id of [b]navlink[/b] you use the following CSS:[code]#navlink a:link, #navlink a:active, #navlink a:visited { color: #FF0000;}#navlink a:hover { color: #00FF00;}[/code]Say that you want another link but want it different you'll just change the id value to different one such as "bodylink":[code]<a href="home.html" id="bodylink">Home</a>[/code]Then with your css you'll do this:[code]#navlink a:link, #navlink a:active, #navlink a:visited { color: #FF0000;}#navlink a:hover { color: #00FF00;}#bodylink a:link, #bodylink a:active, #bodylink a:visited { color: #0000FF;}#bodylink a:hover { color: #FF0000;}[/code]Have a read on CSS syntax over at [a href=\"http://www.w3schools.com/css/css_syntax.asp\" target=\"_blank\"]w3schools.com[/a] for a better understanding of CSS selectors. Quote Link to comment https://forums.phpfreaks.com/topic/6606-having-more-than-one-alink/#findComment-24146 Share on other sites More sharing options...
moberemk Posted April 5, 2006 Share Posted April 5, 2006 Another, probably better way of doing it, would be to use the (.) selector and create a class that you can use over and over again. Quote Link to comment https://forums.phpfreaks.com/topic/6606-having-more-than-one-alink/#findComment-24185 Share on other sites More sharing options...
turbocueca Posted April 5, 2006 Author Share Posted April 5, 2006 I understand +/-, but whats the problem in here, it doesnt work correctly:[code]<html><head><title>Untitled Document</title><style type="text/css"><!--#navlink a:link, #navlink a:active, #navlink a:visited { color: #FF0000;}#navlink a:hover { color: #00FF00;}--></style></head><a href="home.html" id="navlink">Home</a><body></body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/6606-having-more-than-one-alink/#findComment-24193 Share on other sites More sharing options...
wildteen88 Posted April 5, 2006 Share Posted April 5, 2006 Change this:[code]<a href="home.html" id="navlink">Home</a>[/code]to[code]<div id="navlink"><a href="home.html">Home</a></div>[/code]Your CSS should now work. Quote Link to comment https://forums.phpfreaks.com/topic/6606-having-more-than-one-alink/#findComment-24252 Share on other sites More sharing options...
turbocueca Posted April 5, 2006 Author Share Posted April 5, 2006 thanks people for everything, i finally could implement two link styles at my website:[a href=\"http://infocenter.awardspace.com/inter/news2.php\" target=\"_blank\"]http://infocenter.awardspace.com/inter/news2.php[/a] Quote Link to comment https://forums.phpfreaks.com/topic/6606-having-more-than-one-alink/#findComment-24254 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.