Forum Moderators: open
I encountered a problem while setting up a navigation bar for my site. I used css with html (by the link method) and the bar appeared nicely in Dreamweaver. However, it appeared as list (block) in Firefox and IE7 although I coded it to be appeared inline. Could somebody please tell me how to fix this? I'm fairly new with html and css.
CSS Code:
body {background-color: #AC8DC4;
font-family: Arial, Helvetica, sans-serif;
color: #000000;
font-size: 12px;
}
ul#list-nav {
list-style:none;
margin:20px;
padding:0;
width:792px
}
ul#list-nav li {
display: inline;
}
ul#list-nav li a {
text-decoration:none;
padding-top:5px;
padding-bottom:5px;
width:155px;
background:#8867A3;
color:#D0BEDE;
font-weight:bold;
float:left;
text-align:center;
font-size:16px;
}
ul#list-nav li a:hover {
background:#008000;
color:#000
}
HTML:
<center>
<ul id="list-nav">
<li><a href="www.example.org">1</a></li>
<li><a href="www.example.org">2</a></li>
<li><a href="/phpBB3/">3</a></li>
<li><a href="/wiki/">Wiki</a></li>
</ul>
</center>
Thanks a lot!
Best,
fanduy
1. Place the rules in the <head> section, within a <style> element:
<style type="text/css">[your css rules go here]</style>
2. Link to an external stylesheet from within the <head> section:
<link href="mystyles.css" rel="stylesheet" type="text/css">
If you're using the second approach, then make sure you have nothing in the mystyles.css file but your rules. So check for errors in how you bring in the CSS rules - the CSS itself does work for me with that HTML - in IE, FF, Opera and Safari.
The two links below can be your best friends. If you make sure that your html and css validate before you go troubleshooting, then you've eliminated a source of many potential rendering problems. Some types of problems are literally impossible to fix if the mark-up doesn't validate.
W3C Validator - HTML [validator.w3.org]
W3C Validator - CSS [jigsaw.w3.org]
Thanks!
When you are validating an external stylesheet, you should submit that css file directly to the CSS Validator. However, I already checked your CSS rules -- the external stylesheet I built using them did validate.
ul#list-nav {display: inline;
That works on my horizontal lists, using either id= or class=.
[edited by: Marcia at 7:35 am (utc) on Feb. 15, 2008]