Centering a Table

Posted 6 years, 8 months ago (Edited 6 years, 8 months ago) by Sharklore

Hey again, coders! I'm in need of a little help.

I want to make a single table smaller than the text tries to stretch it to be (which I already know how to do; I just change the width to whatever percentage I want it to be), but I'd also like to center the smaller table and I haven't been able to find a way to do that. Am I just messing up something simple, or is there some trick to it?

Thanks!

//Edit

Character I'm working on can be found here!

Pinky

add the class "mx-auto" to your table and it will center it !

Sharklore

The illustrious wicked swoops in to save the day! Thanks so much.

Even though I've been tinkering with HTML since 2012, I'm still a novice... Mind if I ask where exactly I stuff "mx-auto" into the code? I'm sure it goes somewhere, but I'm not seeing an intuitive spot for it.

//edit

Another edit, since I seem to be on a roll with those today. This is what I've been trying.

Pinky

"mx-auto" is a bootstrap class that tells the table to assign the margins on the x axis (so left & right) to auto (which centers things) !

right now you are making a table, setting it's width to 70%, then closing the table. then you make another table and give it the class - you arent centering the table with the width set

so you should do...
table class="mx-auto" style="width:70%;"

you can use a class & inline styling on the same element !

Sharklore

wicked

Well that would explain a lot, wouldn't it! Just did what you said and it worked beautifully. Thank you so much--I really appreciate the help!