0

How do I shorten this code without compromising their function?

.taster a:link, a:visited {
    text-decoration: none; 
    color: #FFFFFF;
}

.taster a:hover , a:active {
    font-size: 120%;
    color: #000000;
}

.contact a:link, a:visited {
    text-decoration: none; 
    color: #FFFFFF;
}

.contact a:hover , a:active {
    font-size: 120%;
    color: #000000;
}    

I would appreciate it if you could help me out with this one.

3
  • Did you check if it works the way you expect? Commented Dec 2, 2014 at 19:38
  • This question would probably be better suited for the Code Review StackExchange site. Commented Dec 2, 2014 at 19:38
  • yeah I did. Currently, I'm shortening by CSS code, particularly this one. If I attach the matching elements to .taster , .contact a:link , a:visited, it doesn't work anymore Commented Dec 2, 2014 at 19:40

3 Answers 3

5

Join matching styles for different selectors with a ,

.taster a:link, .contact a:link, a:visited {
    text-decoration: none; 
    color: #FFFFFF;
}

.taster a:hover, .contact a:hover, a:active {
    font-size: 120%;
    color: #000000;
}

Or if you want it even smaller, try with a minifier.

Sign up to request clarification or add additional context in comments.

3 Comments

a:visited and a:active are global, not part of the .taster or .contact
same as the original question :)
Minifier just remove spaces. Is there tool for your made it ?
2

This is all:

.taster a:link, 
.taster a:visited,
.contact a:link, 
.contact a:visited {
  text-decoration: none; 
  color: #FFFFFF;
}

.taster a:hover, 
.taster a:active,
.contact a:hover,
.contact a:active {
  font-size: 120%;
  color: #000000;
} 

2 Comments

Note that this shares the original post's bug (a:visited is being targeted globally -- twice -- when OP probably means .taster a:visited and .contact a:visited; same with a:active)
@PaulRoub missed that, an edit will be made :) Thanks for pointing it out :)
1
.taster a:link, .taster a:visited, .contact a:link, a:visited {
    text-decoration: none; 
    color: #FFFFFF;
}

.taster a:hover , .taster a:active, .contact a:hover , a:active {
    font-size: 120%;
    color: #000000;
} 

or you can add it different (or one more) class for example "link" (for the first) and "hover" (for the second)

.link a:hover , a:active {
    font-size: 120%;
    color: #000000;
}    
.hover a:link, a:visited{
    text-decoration: none; 
    color: #FFFFFF;
}

2 Comments

Why would you do it like ".link a:hover , a:active" ? Maybe he wants to target only the links inside a taster and contact class...
Right, it depends how it is done - if he is going to use it more than once, twice. For example building complex theme with some parts black and whites with two looks of links, I would use this instead - just writing my links or whatever and add to it correct css without any need to go to styles and add the particular element while coding the site. Because if there will be more classes that will start to be bit long and hard to change it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.