My HTML is as follows:
<ul id='nav'> <li><a href='./'>Home</a></li> <li><a href='/About'>About</a></li> <li><a href='/Contact'>Contact</a></li> </ul>
And my css:
#nav { display: inline; }
However the whitespace between the li’s shows up. I can remove the whitespace by collapsing them like so:
<ul id='nav'> <li><a href='./'>Home</a></li><li><a href='/About'>About</a></li><li><a href='/Contact'>Contact</a></li> </ul>
But this is being maintained largely by hand and I was wondering if there was a cleaner way of doing it.
Several options here, first I’ll give you my normal practice when creating inline lists:
Then the CSS to make it function as you intend:
Obviously I left out the hover and active sets, but this creates a nice block level navigation, and is a very common method for doing this while still keeping with standards. /* remember to tweak to your liking, add color to the background, et cetera */
If you would like to keep it just with text and just inline, no block elements I believe you’d want to add:
Realizing you would like to REMOVE the whitespace, just adjust the margins/padding accordingly.