Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/233851-unable-to-center-text-in-a-table/
Share on other sites

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.