/ Published in: CSS
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<html> <head> <style type="text/css"> ul { list-style-type:none; margin:0 auto; padding:10px; padding-top:6px; padding-bottom:6px; background:#565656; text-align:center; } li { display:inline; } a:link,a:visited { font-weight:bold; color:#FFFFFF; background-color:#98bf21; text-align:center; padding:6px; text-decoration:none; text-transform:uppercase; } a:hover,a:active { background-color:#7A991A; } </style> </head> <body> <ul> <li><a href="#home">Home</a></li> <li><a href="#news">News</a></li> <li><a href="#contact">Contact</a></li> <li><a href="#about">About</a></li> </ul> <p><b>Note:</b> If you only set the padding for a elements (and not ul), the links will go outside the ul element. Therefore, we have added a top and bottom padding for the ul element.</p> </body> </html>