Tony Tony - 1 year ago 52
CSS Question

display: inline not working even with float

I'm trying to create a horizontal nav bar using CSS and display: inline; but I'm having no joy with it. Using

, I am getting a vertical list rather than a horizontal one. I've Googled the web and poured over SO but can't find a fix.

#menu ul {
height: 15px;
padding: 8px 0px;
margin: 0px;
#menu li {
text-decoration: none;
display: inline-block;
padding: 20px;
float: left;
.logo {
font-family: 'Mr De Haviland', cursive;
font-size: 32px;
.logo a {
color: black;
text-decoration: none;
#nav a {
color: black;
text-decoration: none;
#nav {
max-width: 600px;
width: auto;
height: 35px;
font-size: 16px;
font-family: Helvetica, Geneva, sans-serif;
text-align: center;
text-shadow: 3px 2px 3px #666666;
background-color: #999999;
border-radius: 8px;
list-style-type: none;

<!DOCTYPE html>
<html lang="en-gb">

<meta charset="utf-8">
<link href='' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="index.css">
<title>Anthony Jones</title>

<div id="main">
<div class="logo">
<p align="center">
<a class="logo" href="index.html">Anthony Jones</a>

<div id="nav">
<ul style="list-style-type: none;">
<a href="about.html">
<a href="cv.html">
<li>Curriculum Vitae</li>
<a href="services.html">
<a href="random.html">
<a href="contact.html">
<li>Contact Me</li>


ul style="list-style-type: none;"
in the
tag is there because I couldn't remove the bullet points within the index.css file, this was the only solution I could find.

I've tried many variations on the code, rearranged it, deleted and started over and still no joy. Any ideas?

Answer Source

1: you can't wrap an a tag around li. a tag must be inside li.

Like this:

<div id="nav">
<ul style="list-style-type: none;">
<li><a href="about.html">About</a></li>
<li><a href="cv.html">Curriculum Vitae</a></li>
<li><a href="services.html">Services</a></li>
<li><a href="random.html">Random</a></li>
<li><a href="contact.html">Contact Me</a></li>

2: Set li to display: inline

Like this:

#nav li {
    display: inline;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download