[HTML] Text horizontally centered in <td>

Results 1 to 15 of 15
  1. #1
    Sorcerer Supreme Illusion is offline
    Member +Rank
    Mar 2008 Join Date
    C:\Program Files\Adobe\Photoshop\Location
    457Posts

    Post [HTML] Text horizontally centered in <td>

    I sliced an saved my layout and all that, then i changed all the sliced from
    Code:
    <td>
    <img src=images/my-image.png>
    </td>
    to
    Code:
    <td background="images/my-image.png" width="140" height="552">
    so i could put text over it.

    But the text got centered horizontally when the code is like this:
    Code:
           <td colspan="3" width="626" height=552 background=images/content.png>
    this is my text
                </td>



    But it goes up when i write more under it:
    Code:
            <td colspan="3" width="626" height=552 background=images/content.png>
    this is my text
    <br>
    and this is my second text!
                </td>


    What's wrong and how do i fix it?


  2. #2
    The Gamma..? EliteGM is offline
    Grand MasterRank
    Jul 2006 Join Date
    NandolandLocation
    4,077Posts

    Re: [HTML] Text horizontally centered in <td>

    add valign="top" to the TD tag. (<td background="blalba.jpg" width="626" height="552" valign="top">
    That does it !
    Can also add style="text-align: center;" but that's just for centering txt.

    Adding some padding isnt bad too, I use style="padding: 10px;"
    Then if you have long senctences you will not go over the edge of the image.

    USE " IN YOUR TAGS! NOT JUST I.E: width=682 ; use width="682"

  3. #3
    Sorcerer Supreme Illusion is offline
    Member +Rank
    Mar 2008 Join Date
    C:\Program Files\Adobe\Photoshop\Location
    457Posts

    Re: [HTML] Text horizontally centered in <td>

    Okay, thanks allot!

  4. #4
    Hm. foxx is offline
    Grand MasterRank
    Sep 2006 Join Date
    Czech RepublicLocation
    5,256Posts

    Re: [HTML] Text horizontally centered in <td>

    Be clever, learn css.
    Code:
    #shit {
    width: 626px;
    heigh:552px;
    background: url('../images/content.png');
    padding: 10px;
    }
    
    #shit p {
    font-family: Arial;
    padding: 0px;
    margin: 0px;
    margin-left: 220px;
    }
    Code:
    <div id="shit">
     <p>this is my text</p>
     <p>and this is my second text!</p>
    </div>

  5. #5
    Banned Monsta. is offline
    BannedRank
    Jun 2008 Join Date
    England - MerseLocation
    1,221Posts

    Re: [HTML] Text horizontally centered in <td>

    Well, Foxx123, what does <p></p> do?

    I'm having trouble with it :|

  6. #6
    The Gamma..? EliteGM is offline
    Grand MasterRank
    Jul 2006 Join Date
    NandolandLocation
    4,077Posts

    Re: [HTML] Text horizontally centered in <td>

    <p></p>
    Use this then you don't need
    Line1 <br />
    Line2 <br />

    The P stands for 'Paragraph'.

  7. #7
    Grand Master Daevius is offline
    Grand MasterRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [HTML] Text horizontally centered in <td>

    Yep, it's actually 'forbidden' to use <br>'s just for seperating / padding 2 elements vertically. One should use a <p> tag with top and bottom paddings.

    You might want to try and get rid of the whole table, and use CSS like explained here: http://www.htmldog.com

  8. #8
    The Gamma..? EliteGM is offline
    Grand MasterRank
    Jul 2006 Join Date
    NandolandLocation
    4,077Posts

    Re: [HTML] Text horizontally centered in <td>

    Tables are the 'lazy-mans' way of doing a web imo.
    But the simplicity makes me use it.

    Tables arent that bad imo, just DIV's are best =0

  9. #9
    :-) s-p-n is offline
    DeveloperRank
    Jun 2007 Join Date
    Next DoorLocation
    2,097Posts

    Re: [HTML] Text horizontally centered in <td>

    Quote Originally Posted by EliteGM View Post
    Tables are the 'lazy-mans' way of doing a web imo.
    But the simplicity makes me use it.

    Tables arent that bad imo, just DIV's are best =0
    eww I never want to hear that again..

    Tables are dominate over DIVs in almost every way..
    DIVs suck. They're too unpredictable :l They appear in different places all over the screen on different browsers. The least admin-friendly way to display text I've ever used! and I still use divs just only when I need them..

  10. #10
    Grand Master Daevius is offline
    Grand MasterRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [HTML] Text horizontally centered in <td>

    Quote Originally Posted by s-p-n View Post
    eww I never want to hear that again..

    Tables are dominate over DIVs in almost every way..
    DIVs suck. They're too unpredictable :l They appear in different places all over the screen on different browsers. The least admin-friendly way to display text I've ever used! and I still use divs just only when I need them..
    Then you need to learn to use CSS properly. I never had this problem, it looks the same on every browser, with the exception of IE sometimes, but there is always a fix for that. Tables are for tabular data, not layout or positioning.

  11. #11
    Hm. foxx is offline
    Grand MasterRank
    Sep 2006 Join Date
    Czech RepublicLocation
    5,256Posts

    Re: [HTML] Text horizontally centered in <td>

    Quote Originally Posted by EliteGM View Post
    Tables are the 'lazy-mans' way of doing a web imo.
    But the simplicity makes me use it.

    Tables arent that bad imo, just DIV's are best =0
    Tables are for those who can't code and uses photoshop to code for them..

  12. #12
    The Gamma..? EliteGM is offline
    Grand MasterRank
    Jul 2006 Join Date
    NandolandLocation
    4,077Posts

    Re: [HTML] Text horizontally centered in <td>

    I disagree.

    Yes, you can use tables when Photoshop slices your images into them.
    But you can also code them.
    They make a working lay-out.
    Better something then nothing.

  13. #13
    Grand Master Daevius is offline
    Grand MasterRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [HTML] Text horizontally centered in <td>

    Quote Originally Posted by EliteGM View Post
    I disagree.

    Yes, you can use tables when Photoshop slices your images into them.
    But you can also code them.
    They make a working lay-out.
    Better something then nothing.
    Yep, it works with tables, but that doesn't mean it's the right thing to do ;). I can hit a fly using my mobile phone...it works, but it's not meant for it ^^.

    I do agree though, that some things are not possible with CSS, and require tables. HTML is so messed up these days...there should come a new way of making webpages.

  14. #14
    :-) s-p-n is offline
    DeveloperRank
    Jun 2007 Join Date
    Next DoorLocation
    2,097Posts

    Re: [HTML] Text horizontally centered in <td>

    Quote Originally Posted by Daevius View Post
    Then you need to learn to use CSS properly. I never had this problem, it looks the same on every browser, with the exception of IE sometimes, but there is always a fix for that. Tables are for tabular data, not layout or positioning.
    oi.. Well you admitted that divs can't be used for everything tables can be used for.. So I'll say that DIVs are good because of the Z axis.

    But I don't like them because of my lack of knowledge about DIV tags, not CSS.. I think I know CSS very well. It's a stylesheet, and CSS has gotta be the simplest thing before databases..
    In fact, I know the person who has the centering problem can fix his problem by typing a very simple CSS:
    Code:
    .tableDisplay {
    text-align: center;
    }
    and attaching it to a div or table.
    I also know he can do this:
    Code:
    <td align="center"> text</td>
    but the problem is most likely that he has a <p> or <span> tag around his text with the align="left" on it, so it probly won't work anyway..

    Which brings in yet another option:
    Code:
    <p align="center">text goes here</p>

  15. #15
    Grand Master Daevius is offline
    Grand MasterRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [HTML] Text horizontally centered in <td>

    Quote Originally Posted by s-p-n View Post
    oi.. Well you admitted that divs can't be used for everything tables can be used for.. So I'll say that DIVs are good because of the Z axis.

    But I don't like them because of my lack of knowledge about DIV tags, not CSS.. I think I know CSS very well. It's a stylesheet, and CSS has gotta be the simplest thing before databases..
    In fact, I know the person who has the centering problem can fix his problem by typing a very simple CSS:
    Code:
    .tableDisplay {
    text-align: center;
    }
    and attaching it to a div or table.
    I also know he can do this:
    Code:
    <td align="center"> text</td>
    but the problem is most likely that he has a <p> or <span> tag around his text with the align="left" on it, so it probly won't work anyway..

    Which brings in yet another option:
    Code:
    <p align="center">text goes here</p>
    Infact, if you mean the simple CSS markup commands...yes that's easy :). But that's only one part of CSS. What I meant, with CSS, is the use of DIV's and CSS commands to create a layout ;). I thought I knew CSS aswell...till I discovered the use of DIV's ^^.



Advertisement