anchor does not wrap around li. why?

Problem

I have following html and css code in which I want <a> tag to wrap around <li> tags using css.

here is jsfiddle

html

<section class="row header">
            <ul class="nav">
                <li class="navfirst"><a href="#">Contact</a></li>
                <li><a href="#">Home</a></li>
                <li><a href="#">Resume</a></li>
                <li><a href="#">Interests</a></li>
                <li><a href="#">Work</a></li>
                <li class="navlast"><a href="#">Comments</a></li>
            </ul>
        </section>

css

.header .nav {
 margin: 0;
 padding: 0; }
  .header .nav li {
list-style-type: none;
display: inline-block;
padding: 0.5% 1%;
border: 1px solid green; }
.header .nav li.navfirst {
  margin-right: 4%; }
.header .nav li.navlast {
  margin-left: 4%; }
.header .nav li a {
  display: block;
  text-decoration: none;
  border: 1px solid red;
  width: 100%;
  height: 100%; }

here is scss. above css is converted from scss file

.nav {
    margin: 0;
    padding: 0;
    li {
        list-style-type: none;
        display: inline-block;
        padding: 0.5% 1%;
        border: 1px solid green;
        &.navfirst {
            margin-right: 4%;
        }
        &.navlast {
            margin-left: 4%;
        }
        a {
            display: block;
            text-decoration: none;
            border: 1px solid red;
            width: 100%;
            height: 100%;
        }
    }
}
Problem courtesy of: 2619

Solution

Remove the padding from the li tags:

...
display: inline-block;
padding: 0.5% 1%;   <-- padding: 0
border: 1px solid green; 
...

http://jsfiddle.net/qrXWQ/1/

Add padding to the a:

.header .nav li a {
     display: block;
     text-decoration: none;
     border: 1px solid red;
     padding: 5px; 
}

Remove the width: 100% and height: 100% from the rule above, otherwise the padding will mess up the layout...

http://jsfiddle.net/qrXWQ/2/

In the rule above the percent unit will not work because it has no base width/height to apply the % to. You have 3 options: 1) leave the padding in the LI, 2) put the padding in the a with a unit other than % (em fits well here), or 3) use media queries to set a diferent padding for each screen size.

Solution courtesy of: devundef

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.