Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2010
    Posts
    417
    Thanks
    4
    Thanked 1 Time in 1 Post

    unable to center text in a table

    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 ?

    Code:
    <!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>

  • #2
    Senior Coder
    Join Date
    Jan 2005
    Location
    Memphis, TN
    Posts
    1,785
    Thanks
    8
    Thanked 131 Times in 129 Posts
    add display: block; to your span

    You are giving it a width but, a span is inline by default and the width will not be applied unless you change it to be block level.
    Stop making things so hard on yourself.
    i is tugbucket :: help raise tugburg :: Whitehaven Kiwanis


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •