Forum Moderators: not2easy
I'd really appreciate your help with regards to aligning a table to the center of the page using css.
Using the code :
div.align {
text-align: center;
}
It works fine with a pc but not on a mac.Also showing up on netscape aligned to the left.
I'm trying to keep the code validated with xhtml and would prefer not to have to use <table align ="center">
Thanks,
Barry
{
margin-left: 20%
margin-right: 20%
text-align: center;
}
or{margin: 0 20%; text-align: center;} /* the shorthand version */
...to the text-align property you have already set, this may work, you can adjust the % value as it will depend on how big your table is in regard to the page I have used this before on tables with some success
Suzy
You may have an older version of Opera. "margin: auto" works in the current version, in older versions you had to specify left and right separately, ie "margin-left: auto; margin-right: auto;"
div {text-align: centre;} works in NS4, so one way or another it is possible to cover all the bases with valis css.
Thanks for responses
Worked a treat with the code Suzy gave me.
The margin attribute was the key: margin: 0 20%;
Well done Suzy, I really appreciate it !
Have you tried <div align="center"> in your code? Does that validate and work?
This would work but would'nt validate with xhtml.
The tag has been depreciated in html 4.01, so it is on the way out.
Thanks again,
Barry