Is there a simple way to centre a table on a page?
I have not trouble centring text and pictures within cells, but I want to centre the entire table.
Is there something I can add to the HTML coding, or is it even simpler than that somehow?
Any and all help will be greatly appreciated by a real Moodle noob!
It is one of those things that has been difficult with normal css because "text-align" applies to inline content, not to a block-level element like "table" and IE6 does not understand margin:auto. Anyway - try this:
<div style="text-align: center;">
<table style="margin-left: auto; margin-right: auto; width: 100px;"><tbody>
<tr>
<td>AAAAAAAA<br />
</td>
<td>BBBBB<br />
</td>
</tr>
<tr>
<td>CCCCCCC<br />
</td>
<td>DDDDD<br />
</td>
</tr></tbody>
</table>
</div>
Inner table gets centered automatically except in IE6 and outer div should center that table for IE6. You can modify any properties of table and cells in Full screen editor (second row right in editor toolbar) or edit source with <>.
It does not work here (moodle.org forums) but should work on your site - at least on my test moodle sites style attribute is not stripped away.
It is also possible to define styles to theme css files and use class="myclass1" or class="myclass2" in your tables instead of style attributes.
<div style="text-align: center;">
<table style="margin-left: auto; margin-right: auto; width: 100px;"><tbody>
<tr>
<td>AAAAAAAA<br />
</td>
<td>BBBBB<br />
</td>
</tr>
<tr>
<td>CCCCCCC<br />
</td>
<td>DDDDD<br />
</td>
</tr></tbody>
</table>
</div>
Inner table gets centered automatically except in IE6 and outer div should center that table for IE6. You can modify any properties of table and cells in Full screen editor (second row right in editor toolbar) or edit source with <>.
It does not work here (moodle.org forums) but should work on your site - at least on my test moodle sites style attribute is not stripped away.
It is also possible to define styles to theme css files and use class="myclass1" or class="myclass2" in your tables instead of style attributes.
Hi David and Manu
just add attribute align to table tag like this:
<table align="center" width="50%" border="1"><tbody>
<tr>
<td width="100%" valign="top">your text here
</td>
</tr></tbody>
</table><br /><br />
cheers
what I always do in Moodle 1.9x to center a table is: |
just add attribute align to table tag like this:
<table align="center" width="50%" border="1"><tbody>
<tr>
<td width="100%" valign="top">your text here
</td>
</tr></tbody>
</table><br /><br />
cheers
Thanks very much to both of you for your kind assistance. I tried your suggestion first, Maryel, and it worked.
I'm really, really pleased, because it does make my pages look a lot better.
Again, many thanks.
I'm really, really pleased, because it does make my pages look a lot better.
Again, many thanks.
Yes - it's the "good, old way"...
Because align attribute has been deprecated in XHTML strict (in favor of CSS) http://www.w3schools.com/tags/tag_table.asp the pages using "align" don't validate but who cares...
Last time I worked with web code it was HTML 3.0, and that was quite a while ago! So I guess the old-fashioned way probably makes more sense to me at this stage.
I'm really enjoying Moodle, though, and see immense possibilities in it as a teaching tool, so I hope to pick up a few more coding skills as I go along. Clearly it pays, because the WYSIWYG doesn't do it all.
Thanks again for your help!
I'm really enjoying Moodle, though, and see immense possibilities in it as a teaching tool, so I hope to pick up a few more coding skills as I go along. Clearly it pays, because the WYSIWYG doesn't do it all.
Thanks again for your help!