0

I have two different tags with different hierarchy but the same settings, is there any way in that case not to double my code? I tried mixing up the declarations but looks like only one of them will actually enjoy the traits..

section#leftSection nav#leftNav ul li a{
    background-color: #336b98;
    color: #EBEBEB;
    font-family: Arial;
    font-size: 12px;
    text-decoration:none;
}

header#layout2_header nav#headerNav ul li a{
    background-color: #336b98;
    color: #EBEBEB;
    font-family: Arial;
    font-size: 12px;
    text-decoration:none;
} 
0

2 Answers 2

4

You can use comma , to separates multiple selectors that have the same styles:

section#leftSection nav#leftNav ul li a, header#layout2_header nav#headerNav ul li a{
    background-color: #336b98;
    color: #EBEBEB;
    font-family: Arial;
    font-size: 12px;
    text-decoration:none;
} 
Sign up to request clarification or add additional context in comments.

4 Comments

wow your fast.. great, my mistake was that:
section#leftSection,header#layout2_header nav#headerNav,nav#leftNav ul li a
You could also give your ul tags a class and just have ul.classname li a as the selector. This is a good solution anyway +1
Interesting, it gets very complex and yet so comportable.
1

Separate the selectors with a comma , open the curly brackets add your code and hey presto...

section#leftSection nav#leftNav ul li a, 
header#layout2_header nav#headerNav ul li a{
    background-color: #336b98;
    color: #EBEBEB;
    font-family: Arial;
    font-size: 12px;
    text-decoration:none;
} 

It's good to keep each selector on it's own line to make your code more readable.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.