You have to keep in mind that the text-align property is inherited.
There are several ways to approach the problem. I'll talk about two of the most common.
Let's say you have the images and the links formatted in the following way:
Code:
<div id='nav'>
<img src='' alt='Image 1' />
<img src='' alt='Image 2' />
[list]
<li><a href='#'>Link 1</a></li>
<li><a href='#'>Link 2</a></li>
<li><a href='#'>Link 3</a></li>
<li><a href='#'>Link 4</a></li>
<li><a href='#'>Link 5</a></li>
</ul>
</div>
This is a pretty common setup for navigation using HTML && CSS or XHTML && CSS. The navigation is sandboxed in a <div> element. The links are structured in lists and styled with CSS.
If you want to center the images, but not the text of the links you could go with this approach.
Code:
div#nav {
text-align: center;
}
div#nav ul {
text-align: left;
}
Remember that the text-align property is inherited. To circumvent the inheritance, you use the cascade to override it. The cascade applies styles based on the specificity of the selector (discussed in Chapter 7 in my book).
The second approach is not to use the cascade at all, but to make the images into block elements (instead of inline replaced elements). Not going to go into explaining all that, but the concept goes like this.
Code:
div#nav img {
display: block;
margin: auto;
}
The images are made into block elements, and then centered with margin: auto;.
In Chapter 10 I talk about centering block elements with the margin: auto; declaration. inline vs. block is also discussed in that chapter.
Hope that gives you an idea of how to proceed.
Regards,
Rich
--
[
http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design