I have several <li>
items centered and displaying inline within <ul>
tags, but I cannot seem to get the <ul>
itself to center on the page. You can see the slight indention problem on this JSFiddle.
Here is the HTML for the list:
<ul>
<li><a href="/index.html" title="Home">Home</a></li> |
<li><a href="/knowing.html" title="Knowing">Knowing</a></li> |
<li><a href="/caring.html" title="Caring">Caring</a></li> |
<li><a href="/working.html" title="Working">Working</a></li> |
<li><a href="/living.html" title="Living">Living</a></li> |
<li><a href="/opportunities.html" title="Opportunities">Opportunities</a></li> |
<li><a href="/medicalservices.html" title="Medical Staff Services">Medical Staff Services</a></li>
<br> asdf © 2014
</ul>
Here is the CSS:
body {
font-size: 75%; /* Base browser font size is 14px */
font-family: Arial, Helvetica, sans-serif;
line-height: 1.5;
text-align: center;
margin: 0 auto;
width: 75%;
clear: both;
}
a, a:link, a:hover, a:active, a:visited {
text-decoration: none;
}
ul {
margin: 0 auto;
}
li {
text-align: center;
display: inline;
}
.footer a:link, .footer a:visited, .footer a:active, .footer a:hover, {
text-align: center;
color: #cccccc;
}
Annoyingly, the list centers if I delete the <ul>
tags from the HTML, but that is improper markup and potentially dangerous/problematic.
I've tried a few other suggestions from similar questions, such as positioning a container div left at width: 100%;
with position: relative;
, positioning the <ul>
div left and floating it left 50%, and then positioning the <li>
items left and floating them right 50%, but that doesn't work with regard to the |
separators that I have in-between each <li>
item.
Is my markup somehow still incorrect? Do I have some conflicting CSS values that prevent it from working? Do <ul>
lists always indent, no matter what?
EDIT: Added CSS code directly to the post.
so the "|" signs and copyright information should not be there.
– Tanel Eero Feb 19 '14 at 20:04