Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Centering nested tables 1

Status
Not open for further replies.

brk1221

MIS
Jan 29, 2002
230
US
Hi, I'm using the following code to center a table in my html page:

html file
<table class="center">
...
</table>

css file
table.center {margin-left:auto; margin-right:auto;}
body {text-align:center;}

This works on a single table on a test page, but on my working page there are nested tables. Is there a way for this to inherit to all tables with out coding each table?

Thanks
Tim
 
Yes. There are several ways to do this.

If you want all the tables to be centered, just use

Code:
table {...

If you just want all of the nested tables, you could try (not tested)

Code:
table.center, table.center table { ...

which essentially says to center the table with a class center and center any table within a table with that class.

There are other ways as well.

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Whatever styles you want to put in there:

table {margin-left:auto; margin-right:auto;}

table.center, table.center table {margin-left:auto; margin-right:auto;}
 
??? not sure what those dots mean ???

Three dots mean ... um ... err ... you know???


And you did not only use ellipsis in your own post, you also already had styles within {...}.

Look! There! Again: ...

Sometimes it makes me wonder how you people get into management. Sorry, if you find this too offensive, but that's hillarious.

Bye, Olaf.
 
OK, point taken. The ellipsis in the original post was copied code.
 
Hello Tim,

The ellipsis in the original post was copied code.

The ellipsis in traingamers reply was standing for omitted code, you had in your original post.

If you say the ellipsis in
<table class="center"> ... </table>
was also copied, then I can tell you, this ellipsis also simply means omission of further html, as it does not matter for the CSS behavior of the html table, all that matters is the class="center" attrbute and the CSS for that center class you posted.

And all that matters in traingamers reply is the change of what's before the curly braces in the CSS code. The rest of the CSS can stay as it was.

And it's quote common not only in forums or code to use ellipsis in it's meaning of omission. There is no special technical meaning, eg it does not mean you need the ellipsis in your CSS file.

It seems hard for you to cope with code, it's not your world. But there's two things you can try, copy the code you're given and see it does not work, and then take your common sense and knowledge about ellipsis and fill in the omission with what you already had and see it work.

No reason to ask back, and especially not to ask about "those dots". You've made a bad impression.

Nevertheless, don't let yourself be put off by me, I'm only an occasional poster here. You're welcome. Plus I like your humor in "taking that point", even if it wasn't humor.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top