jason310771 Posted April 15, 2011 Share Posted April 15, 2011 i have tried to place the 'TEXT TO CENTER' in the center of the page using SPAN but does not seem to work, i have also tried to use <p> instead but still the bordered box is left aligned. I would center the whole table but this then messes up all the text and I would have to left align all text, adding even more code. How can I center just this section without having to recode the rest of the page ? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <table style="border: 0px solid rgb(54, 95, 145); text-align: left; width: 600px; height: 172px; font-size: 7pt;" border="0" cellpadding="2" cellspacing="0"> <tbody> <tr valign="top"> <td colspan="2" bgcolor="#eaeaea" style="width: 600px;"> <blockquote> <!-- only edit below this line --> <br><span style="width: 600px; border: 2px solid #41A808; font-size: 12pt; padding: 5px; margin-bottom: 5px; text-align: center; font-weight: bold; color: #002060;">TEXT TO CENTER</span><br> <!-- no edit below this line --> </blockquote> </td> </tr> </tbody> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/233851-unable-to-center-text-in-a-table/ Share on other sites More sharing options...
sunfighter Posted April 16, 2011 Share Posted April 16, 2011 Please do not use inline styles, use css. Is this close to what you want? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> table{ border: 1px solid rgb(54, 95, 145); text-align: left; width: 600px; height: 172px; font-size: 7pt; } #center_box{ width: 600px; border: 2px solid #41A808; font-size: 12pt; padding: 5px; //margin-bottom: 5px; text-align: center; font-weight: bold; color: #002060; } </style> </head> <body> <table cellpadding="2" cellspacing="0"> <tbody> <tr> <td colspan="2" style="width: 600px; background-color: #eaeaea;"> <blockquote> <!-- only edit below this line --> <div id="center_box"> TEXT TO CENTER </div> <!-- no edit below this line --> </blockquote> </td> </tr> </tbody> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/233851-unable-to-center-text-in-a-table/#findComment-1202218 Share on other sites More sharing options...
mat3000000 Posted April 16, 2011 Share Posted April 16, 2011 <table align="center"> Quote Link to comment https://forums.phpfreaks.com/topic/233851-unable-to-center-text-in-a-table/#findComment-1202299 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.