15. Links


#1

So I am here just wondering about something. Whenever I use the 'a:visited' the link doesn't have to be visited, It automaticly is visited. For example:

HTML Code:

<!DOCTYPE html>
<html>
	<head>
		<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
		<title></title>
	</head>
	<body>
		<div>
			<a href="http://www.codecademy.com">Codecademy</a>
			<a href="http://www.codecademy.com">Codecademy</a>
			<a href="http://www.codecademy.com">Codecademy</a>
		</div>
	</body>
</html>

CSS Code:

a:link {
            text-decoration:none;
            color:#008B45;
       }

a:hover {
            color:#00FF00;
        }
        
a:visited {
            color:#EE9A00;
          }

The 'codecademy' links are always orange, no matter if I hover over them, click them, they are always orange. Any help?


#2

i would like to see you html code

if you edit/update your question, leave a reply so i get a notification. Your html code is not visible, take the following steps to make your code visible:

select your code and press ctrl + k (or cmd + k if you use a mac)

if this instructions are unclear, you can also insert 3 backticks before and after your code, like so:

```
<p>visible</p>
```

the backtick is located above the tab key on your keyboard


#3

Here, I edited it. .


#4

The links are compared to your browser history, so it make sense they all are color #EE9A00

for a:hover to work, a:hover should be after a:visited:

a:visited {
            color:#EE9A00;
          }
a:hover {
            color:#00FF00;
        }

you don't have a click event? That would be a:active, you should that one as last.


#5

thank you very much.


#6

thanks it was agreat help!!! i was stuck there for a great lot of time ,but does this means that a:hover is placed before a:visited by default as in it is given according to syntax or is this related to some way in which css interprets these elements.


#7

i am confused by that, you write the code, so you place a:hover before a:visited. css uses a point system (if you want i can give you an extensive article on this). Lets look at this example, now take it from me these two css selectors have the same amount of points. If the points are equal, css decide based on order, the last rule is applied. If you where to swap them, the text will become red.

You have the same with a:visited and a:hover, they are also equal in points, so order matters. Make sense?


#8

thanks a lot that really clears a lot for me ,i was really stuck thinking about the problem in this exercise thanks once again.


#9

2 posts were split to a new topic: 15. links


#11