Jump to content

Center align table with CSS

Recommended Posts

Hi, I can simply use the following tag to horizontally align a table to center:

<table align="center" class="centertable">

I would like to use the CSS to do the same but somehow I cannot make it work. here is how i tried. Will appreciate help.

.centertable {align:center;}

with best regards,rnv

Link to post
Share on other sites
.centertable{  width: 500px;  //need to give the element some sort of width  margin: 0px auto;  //how to center a block level element, given that you have given it a width}

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...