3

I have a problem regarding CSS styling for my list.

Here is the code.

CSS

NAV {
width: 940px;
height: 50px;
float: left;
font-family: Geneva,Arial;
border: 1px solid #000000;
background-color: #D0DBF0;}

NAV ul {
    margin: 0px auto;
    padding-top: 15px;
        padding-left: 70px;
    list-style-type: none;
}
NAV li {
    display: inline;

}

NAV li a {
    float: left;
    text-align: center;
    border-right: 2px solid #00DBF0;
    width: 100px;  
    font-size: 14px; 
    padding: 0px 10px;
    color: #0000FF;
    text-decoration: none;
}

HTML

<NAV>
        <UL>
            <LI><a href="#">Home</a></LI>
            <LI><a href="#">About Us</a></LI>
            <LI><a href="#">Contact Us</a></LI>
            <LI><a href="#">Red Widgets</a></LI>
            <LI><a href="#">Blue Widgets</a></LI>
            <LI><a href="#">Green Widgets</a></LI>
        </UL>
    </NAV>

So here i have designed everything for navigation list, but for the first list i.e home.

<LI><a href="#">Home</a></LI> i want right border. please help me.

Nandu
  • 3,076
  • 8
  • 34
  • 51
Pavan Nadig
  • 1,469
  • 3
  • 11
  • 13

2 Answers2

8

You can do it using the :first-child pseudo-class:

nav li:first-child

or

nav li:first-child a

depending on whether you want to target the list item (<li>) or anchor (<a>).

Anthony Grist
  • 38,173
  • 8
  • 62
  • 76
  • note that i have already given right border to all the `
  • ` in styling `
  • – Pavan Nadig Jan 29 '13 at 12:07
  • yup! that makes it :) thank you @AnthonyGrist. now its my time to learn pseudo-class! :D – Pavan Nadig Jan 29 '13 at 12:40
  • li:nth-of-type(even){ background-color: red; } li:nth-of-type(odd){ background-color: yellow; } – ashishSober Mar 02 '17 at 09:03