MarcosFM Posted May 10, 2017 Share Posted May 10, 2017 Hi! I am reading the HTML5 tutorial from www.w3schools.com. All the examples I've tried have worked well, but not the following one: I want to change the link colours of one of my pages. The "visited", "active" and "hover" are working, but not "link", I don't know why. Could anyone help? This is what I have put in a .css file: <style> a:link { color: black; background-color: transparent; text-decoration: none; } a:visited { color: red; background-color: transparent; text-decoration: none; } a:hover { color: green; background-color: transparent; text-decoration: underline; } a:active { color: yellow; background-color: transparent; text-decoration: underline; } </style> Thanks! Link to comment Share on other sites More sharing options...
dsonesuk Posted May 10, 2017 Share Posted May 10, 2017 (edited) IF in a FILE? You don't require <style> or </style>, just the file to have extension .css. The style tags are only required in pages where styling is inline and on the page itself and between the <head>...</head> tags. Edited May 10, 2017 by dsonesuk Link to comment Share on other sites More sharing options...
Sunamena Posted May 10, 2017 Share Posted May 10, 2017 Your code is fine. It works over here. Did you try it in different browsers? I used Chrome. Remember, if you ever visited the page, the color will be selected FROM visited, and not from link. Delete your cookies, close your browser, or try to type a link to a website your sure you have not yet visited. Link to comment Share on other sites More sharing options...
MarcosFM Posted May 10, 2017 Author Share Posted May 10, 2017 Thanks for your quick answers! Following dsonesuk advice, I have removed the tags <style> and </style> from my .css file and everything works now. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now