Jump to content

Recommended Posts

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.
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]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.