HTML text alignment in a TD

Discussion in 'OT Technology' started by Euclid, Jul 11, 2007.

  1. Euclid

    Euclid New Member

    Joined:
    Apr 19, 2004
    Messages:
    8,139
    Likes Received:
    0
    Location:
    Nashville, TN
    I'm having trouble getting my html to render the same way in different browsers.

    Code:
    <table border=0> <tr> <td align=right style="text-align: right"><b>58<br><u>+ 17</u></b></td> </tr> </table>
    I'm trying to get display a vertical arithmetic problem so I decided to use a borderless table and right-align the text inside. However, I found that Opera on my Mac was not respecting the ALIGN attribute on the TD element. That's why I threw in the redundant STYLE attribute, and it seems to work. Is there anything else I can do to ensure that this will work in all browsers?
     
  2. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    Try making a CSS stylesheet.
     
  3. Euclid

    Euclid New Member

    Joined:
    Apr 19, 2004
    Messages:
    8,139
    Likes Received:
    0
    Location:
    Nashville, TN
    Unfortunately that is beyond the scope of what I can control. I'm writing items for a math test, and the system uses HTML, but I enter the items into a form sort of like entering a reply on a web forum.

    Is the STYLE attribute not supported everywhere stylesheets are?
     
  4. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    You need to set a WIDTH for the table or the td -- otherwise the browser really doesn't have anything to align to.
     
  5. ChrisPokorny

    ChrisPokorny New Member

    Joined:
    Jul 9, 2007
    Messages:
    3
    Likes Received:
    0
    Location:
    Cleveland
    I believe the text-align:right method you chose originally would be suitable, as long as you name a width to be safe, as Slid mentioned. However, here's an alternative that should also work (I'm sure you probably considered this as well):

    Code:
     <table style="border-bottom:1px solid #000; font-weight: bold;" cellpadding="0" cellspacing="0" border="0">
     <tr><td></td><td>58</td></tr>
     <tr><td>+&nbsp;</td><td>17</td></tr>
     </table>
     
  6. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    tables are not designed for this... stop using them.
     
  7. Hate Crime

    Hate Crime Don't Hate OT Supporter

    Joined:
    Mar 12, 2006
    Messages:
    5,255
    Likes Received:
    0
    Location:
    Minnesota
    :07:

    :hsd:
     
  8. Euclid

    Euclid New Member

    Joined:
    Apr 19, 2004
    Messages:
    8,139
    Likes Received:
    0
    Location:
    Nashville, TN
    I'm open to suggestions.
     
  9. Euclid

    Euclid New Member

    Joined:
    Apr 19, 2004
    Messages:
    8,139
    Likes Received:
    0
    Location:
    Nashville, TN
    Ultimately, I still want right alignment within those cells though. For example if adding 58 to 1,024 I want the place value columns to line up.
     
  10. Euclid

    Euclid New Member

    Joined:
    Apr 19, 2004
    Messages:
    8,139
    Likes Received:
    0
    Location:
    Nashville, TN
    Thanks! This is the kind of advice I was hoping for. The only thing is, I don't know how to come up with a WIDTH value.

    I mean, the point of using the table was so that I could position the problem on the left side of the page, but keep the text inside right-aligned.

    It seems to be rendering fine now without the WIDTH. I was thinking there was a website where you could plug in some HTML and it would return image files of how it renders on many different browsers / platforms. That's what I really need!
     

Share This Page