[web] css syntax for this

Started by
11 comments, last by Genjix 18 years, 11 months ago

<html>
<head>

<style>
#menu a:link
{
	color: #00ff00;
}
#menu a:visited , a:hover , a:active
{
	color: #ff0000;
}
</style>

</head>
<body>

<div class="menu">
	<a href="http://www.google.com">google</a>
</div>

</body>
</html>

[Edited by - Genjix on May 17, 2005 1:25:04 PM]
Advertisement
Did you have a question?
Free Mac Mini (I know, I'm a tool)
i don't really understan the question.
DinGY
Yesterday is history.Tomorrow is a mystery. Today is a gift"
I don't either but I can guess!

I think he wants to know if the syntax of his CSS is correct for that file. He wants to edit the look of the link to google with CSS by assigning properties to the menu class that is assigned to the google link.

I dont know about using #menu since I don't use anything like that and therfore I guess it would be incorrect however I do remember seeing something about assigning IDs using #foo (example)

Bell rung and I have to run to art before I get a detention for being late =
Go to www.webmonkey.com and look at the CSS section there. It will show you the correct syntax and how to control the looks of links and whatnot.

~Brandon Haston~
If you're having a problem with the styles not being applied it is probably because in your stylesheet you are specifying that the style will only be applied to things with id="menu" not class="menu". Change the '#' to a '.' in your stylesheet and it should work.
oh sorry for not being clear enough.

basically it just doesn't work.
<html><head><style>.menu a:link{	color: #00ff00;}.menu a:visited , a:hover , a:active{	color: #ff0000;}</style></head><body><div class="menu">	<a href="http://www.google.com">google</a></div></body></html>

makes the link green, but hovering does not work.

<html><head><style>#menu a:link{	color: #00ff00;}#menu a:visited , a:hover , a:active{	color: #ff0000;}</style></head><body><div class="menu">	<a href="http://www.google.com">google</a></div></body></html>

makes the link my browsers default but hovering works

<html><head><style>.menu a:link{	color: #00ff00;}#menu a:visited , a:hover , a:active{	color: #ff0000;}</style></head><body><div class="menu">	<a href="http://www.google.com">google</a></div></body></html> 

just makes it green (hovering doesn't work).


I simply assumed I wasn't using selectors in the correct way and someone would pick up on it.
I know your problem.
"a" in a:link is like the

tag properties. Behaves the same way when assigning the different styles and such. So the next part of a:link (link) is the status of a. When the mouse hovers over it you gotta tell CSS what it should do to the HTML.

so type this...

<style>

a:link {
#00F673;
}
a:hover {
#000333;
}
a:visited {
#444200;
}
a:active {
#8790F2;
}

</style>

should work fine

~Brandon Haston~

While in CSS, the "#" sign denotes things you're assigning an ID, and "." is used for CLASS. If you use neither, the browser assumes you're changing a preexisting tag. Both "#" and "." serve the same function, so I assume a distinction is only made to support scripting languages. For HTML/CSS though, the above is all you need to know.

EDIT: By the way, I'm pretty sure "A:VISITED" is supposed to appear after "A:ACTIVE".
____________Numbermind StudiosCurrently in hibernation.
Quote:Original post by I Like Bread

EDIT: By the way, I'm pretty sure "A:VISITED" is supposed to appear after "A:ACTIVE".


Could be. Im not saying that you HAVE to write the css like I typed it up. I was just giving a general idea =) So if the css doesn't work, Try I Like Bread's info and put Active before Visited. Hell just do it anyways to save you the trouble =)
Above poster (Anony) was me!
=)

This topic is closed to new replies.

Advertisement