I'm having trouble getting tables to center using CSS. It seems to work in Netscape, but not IE.
Here is a line from my CSS file, which is suppose to center the table it is applied to.
.pagetable {
border: thick #666666 inset;
background-color: #666666;
margin-left: auto;
margin-right: auto;
width: 700px
}
Any suggestions on how to make the tables center in IE using CSS would be greatly appreciated. Thanks! Add a text-align:center to your rule.I suppose you're referring to a slightly older version of IE. IE6 should recognize the auto margins, but older versions, like IE5 and IE5.5 do not and thus you must use Ray's suggestion of using text-align: center. This works because IE allows you to align block-level elements via text-align, where it should only apply to inline-level elements. Another non-standard IE thing here.I'm using IE build 6.0.2800.1106. I added the text-align: center rule, but it still didn't work in IE. The class now looks like this:
.pagetable {
border: thick #666666 inset;
background-color: #666666;
margin-left: auto;
margin-right: auto;
text-align: center;
width: 700px}
Any other suggestions?Please provide the markup you're working with too; else, we can't really help much.What do you mean by "markup" ?
This is how my calling the class:
<table class="pagetable">Sorry; I just mean the rest of the HTML you're working with.If you click on the link for my homepage, then view source, that's what I'm working on.<!-- m --><a class="postlink" href="http://www.hotdesign.com/seybold/Thanks">http://www.hotdesign.com/seybold/Thanks</a><!-- m --> for that info. You've given me some good stuff to think about. I think I may redesign the source code on my web site.You're quite welcome. Thankfully you have taken this in a good way and realize that I'm trying to help you. Believe me — using CSS and semantically meaningful markup, you'll have a much easier time creating this layout than if you were to use tables. Tables are for tabular dat and tabular data only; trying to create something else with them (e.g., a layout, etc.) will never be practical due to the fact that it simply wasn't what they were created for.
Here is a line from my CSS file, which is suppose to center the table it is applied to.
.pagetable {
border: thick #666666 inset;
background-color: #666666;
margin-left: auto;
margin-right: auto;
width: 700px
}
Any suggestions on how to make the tables center in IE using CSS would be greatly appreciated. Thanks! Add a text-align:center to your rule.I suppose you're referring to a slightly older version of IE. IE6 should recognize the auto margins, but older versions, like IE5 and IE5.5 do not and thus you must use Ray's suggestion of using text-align: center. This works because IE allows you to align block-level elements via text-align, where it should only apply to inline-level elements. Another non-standard IE thing here.I'm using IE build 6.0.2800.1106. I added the text-align: center rule, but it still didn't work in IE. The class now looks like this:
.pagetable {
border: thick #666666 inset;
background-color: #666666;
margin-left: auto;
margin-right: auto;
text-align: center;
width: 700px}
Any other suggestions?Please provide the markup you're working with too; else, we can't really help much.What do you mean by "markup" ?
This is how my calling the class:
<table class="pagetable">Sorry; I just mean the rest of the HTML you're working with.If you click on the link for my homepage, then view source, that's what I'm working on.<!-- m --><a class="postlink" href="http://www.hotdesign.com/seybold/Thanks">http://www.hotdesign.com/seybold/Thanks</a><!-- m --> for that info. You've given me some good stuff to think about. I think I may redesign the source code on my web site.You're quite welcome. Thankfully you have taken this in a good way and realize that I'm trying to help you. Believe me — using CSS and semantically meaningful markup, you'll have a much easier time creating this layout than if you were to use tables. Tables are for tabular dat and tabular data only; trying to create something else with them (e.g., a layout, etc.) will never be practical due to the fact that it simply wasn't what they were created for.