SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Addict
    Join Date
    Aug 2008
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    align text in tables

    I'm trying to get the text in tables to align with each other.

    They're displaying like this

    Nutrition First Fitness
    772 south blueridge lane
    Alpine, Utah

    I would like them to be aligned like this

    Nutrition First Fitness
    772 south blueridge lane
    Alpine, Utah


    Here is the code www.ProfessionalTrainerNetwork.com

    <TABLE ALIGN=center
    width="800" border="0" cellspacing="0" cellpadding="0" text-align="center">

    <tr align="center" valign="top">
    <!--- Company Name --->
    <td> Nutrition First Fitness&nbsp;</td>
    <td> Optimum Fitness&nbsp;</td>
    <td> Alpine Fitness&nbsp;</td>
    </tr>
    </table>

    <table ALIGN="center" width="800" border="0" cellspacing="0" cellpadding="0">
    <!--- Street Address --->
    <tr align="center" valign="top">
    <td>772 South Blueridge lane&nbsp;</td>
    <td>772 South Blueridge lane&nbsp;</td>
    <td>772 South Blueridge lane&nbsp;</td>
    </tr>
    </table>

    <table ALIGN="center" width="800" border="0" cellspacing="0" cellpadding="0">
    <!--- City, State, Zip code --->

    <tr>
    <td>Alpine, Utah 84004 &nbsp;</td>
    </tr>
    </table>

  2. #2
    SitePoint Wizard webcosmo's Avatar
    Join Date
    Oct 2007
    Location
    Boston, MA
    Posts
    1,480
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    put align="left" for <td> tags.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    You really ought to get all those deprecated attributes out of your HTML and use the correct CSS instead.

    td {text-align:left;}
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Wizard silver trophybronze trophy
    Join Date
    Jul 2008
    Location
    New York, NY
    Posts
    1,432
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @BrianBam

    It could be argued that the <address> tag or microformats would be a better option. If you decide to still use a table to lay out your information, listen to Felgall.

  5. #5
    SitePoint Zealot
    Join Date
    Oct 2007
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, css is best for table alignment

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The address tag isn't really intended for that purpose (it is intended to identify the contact address of the web site owner) which is why the address microformat was created specifically for formatting street addresses.

    If you have a lot of addresses to go on one page then perhaps the best way to format them all would be a table with a single td for each address with each address itself using the address microformat.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  7. #7
    SitePoint Wizard silver trophybronze trophy
    Join Date
    Jul 2008
    Location
    New York, NY
    Posts
    1,432
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.w3.org/TR/REC-html40/stru...l.html#h-7.5.6

    The ADDRESS element may be used by authors to supply contact information for a document or a major part of a document such as a form. This element often appears at the beginning or end of a document.

  8. #8
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The ADDRESS element may be used by authors to supply contact information for a document or a major part of a document such as a form. This element often appears at the beginning or end of a document.
    Which is why <address> would not be appropriate for those addresses which are not contact information for the current document.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  9. #9
    SitePoint Wizard silver trophybronze trophy
    Join Date
    Jul 2008
    Location
    New York, NY
    Posts
    1,432
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Which is why <address> would not be appropriate for those addresses which are not contact information for the current document.
    Correct, I looked it up and posted as you said it

  10. #10
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,702
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Addresses is one of the few instances where the <br> tag is semantically appropriate. Addresses aren't lists. They are information strings, with line breaks inserted according to specific national standards. You can use microformats if you wish, but if you just want to keep it simple, use this:
    Code html4strict:
    Nutrition First Fitness<br>
    772 south blueridge lane<br>
    Alpine, Utah
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  11. #11
    Non-Member
    Join Date
    Oct 2008
    Location
    Banned
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    Congrats on 2000 posts


Tags for this Thread

Bookmarks

Posting Permissions

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