7 Replies - 644 Views - Last Post: 26 October 2013 - 10:37 AM

#1 aidenkael  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 66
  • Joined: 22-October 13

Changing link colors?

Posted 25 October 2013 - 02:01 PM

So, I want to change the link color for all links to black for just the div container for nav. Normally I would stick the code inside the body element of my css, but I'm not sure how to do it for just the div.nav_bar. Am I able to stick it inside the .nav_bar section of the css? If so, where? it doesn't seem to accept it where I am putting it....
Is This A Good Question/Topic? 0
  • +

Replies To: Changing link colors?

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3322
  • View blog
  • Posts: 11,233
  • Joined: 12-December 12

Re: Changing link colors?

Posted 25 October 2013 - 02:17 PM

If you post some of the relevant html, wrapped in code-tags, then we will have a clearer idea of what the css-selector should be.

If the div has class-name nav_bar then it would be:

.nav_bar a { /* etc. */ }

using a:link etc.. to change the LVHA colours.

It won't matter where in the css-rules you place this, unless there is a more specific rule elsewhere, or other rules with the same specificity further down the file.

This post has been edited by andrewsw: 25 October 2013 - 02:19 PM

Was This Post Helpful? 0
  • +
  • -

#3 aidenkael  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 66
  • Joined: 22-October 13

Re: Changing link colors?

Posted 25 October 2013 - 02:24 PM

Here is the css code that I have tried:

.nav_bar
{
	position:absolute;
	top:10%;
	left:1%;
	width:15%;
	height:79%;
	background-color:#808080;
    a:link {color:#000000;}
    a:visited {color:#000000;}
}


This code isn't changing the link colors
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3322
  • View blog
  • Posts: 11,233
  • Joined: 12-December 12

Re: Changing link colors?

Posted 26 October 2013 - 03:16 AM

Yeah, that's not correct. You cannot nest selectors in css.

Where did you get this from? I hope you are not guessing :whistling:

htmldog css tutorial
Was This Post Helpful? 1
  • +
  • -

#5 aidenkael  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 66
  • Joined: 22-October 13

Re: Changing link colors?

Posted 26 October 2013 - 05:19 AM

View Postandrewsw, on 26 October 2013 - 03:16 AM, said:

Yeah, that's not correct. You cannot nest selectors in css.

Where did you get this from? I hope you are not guessing


Not guessing:P that was legit what I was taught. Kids, this is why you pay attention in high school instead of getting suspended for kick flips in the hallway. Get good grades or you go to community college for a year where they fill your head with things like "the easiest way to define a style for an individual div is to nest the css", forcing you to teach yourself even after you get into a University:p I will update the code here when I write it!
Was This Post Helpful? 0
  • +
  • -

#6 aidenkael  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 66
  • Joined: 22-October 13

Re: Changing link colors?

Posted 26 October 2013 - 09:26 AM

So, I wanted to put the working code here so anyone with a similar problem can see a fix in action. What I did was just un-nest my values.

.nav_bar
{
    position:absolute;
    top:15%;
    left:1%;
    width:12%;
    height:74%;
    background-color:#eeeeee;
    padding:3px;
}
.nav_bar a:link
{
    color:#000000;
}
.nav_bar a:visited
{
    color:#000000;
}


Hope this will help anyone else with this issue!
Was This Post Helpful? 1
  • +
  • -

#7 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3322
  • View blog
  • Posts: 11,233
  • Joined: 12-December 12

Re: Changing link colors?

Posted 26 October 2013 - 10:31 AM

Just for the thrill, if you are using the same rules you can combine them:

.nav_bar a:link, .nav_bar a:visited {
    color: #000000;
}

However, many people, myself included, would keep them separate in case we later decide to add different rules.

It is also recommended to supply all four pseudo-selectors - link, visited, hover, active - in this order LVHA (love-hate). But.. it's not significant ;) and most people don't bother.
Was This Post Helpful? 1
  • +
  • -

#8 aidenkael  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 66
  • Joined: 22-October 13

Re: Changing link colors?

Posted 26 October 2013 - 10:37 AM

View Postandrewsw, on 26 October 2013 - 10:31 AM, said:

Just for the thrill, if you are using the same rules you can combine them:

.nav_bar a:link, .nav_bar a:visited {
    color: #000000;
}

However, many people, myself included, would keep them separate in case we later decide to add different rules.


That's why I did them separately :P Depending on backgrounds, and other things I may change them at some point.

View Postandrewsw, on 26 October 2013 - 10:31 AM, said:

It is also recommended to supply all four pseudo-selectors - link, visited, hover, active - in this order LVHA (love-hate). But.. it's not significant ;)/> and most people don't bother.


It is recommended, however I won't be changing color on hover and I have never seen the point in changing on active. Generally the webpage moves to fast for it to even really have an effect....
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1