how to center text in css ?

Discussion in 'HTML' started by richard, Sep 22, 2006.

  1. richard

    richard Guest

    Actually, I need to know how to put the text in the middle of the division.
    As I did with tables.
    Vertical-align doesn't seem to be recognized.

    www.1-small-world.com/index2.html
     
    richard, Sep 22, 2006
    #1
    1. Advertising

  2. richard wrote:
    > Actually, I need to know how to put the text in the middle of the division.
    > As I did with tables.
    > Vertical-align doesn't seem to be recognized.
    >
    > www.1-small-world.com/index2.html
    >


    Look it up for yourself and see why...

    http://www.w3.org/TR/CSS21/propidx.html

    property: 'vertical-align'
    applies to: inline-level and 'table-cell' elements

    DIV is neither. You can set DIV to "display: table-cell;" ...but guess
    what? You guessed it, it will not work in IE. Other options are padding
    and line-height all a bit messy.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Sep 22, 2006
    #2
    1. Advertising

  3. richard

    richard Guest

    "Jonathan N. Little" <> wrote in message
    news:7f2c8$451341a7$40cba7ac$...
    > richard wrote:
    >> Actually, I need to know how to put the text in the middle of the
    >> division.
    >> As I did with tables.
    >> Vertical-align doesn't seem to be recognized.
    >>
    >> www.1-small-world.com/index2.html
    >>

    >
    > Look it up for yourself and see why...
    >
    > http://www.w3.org/TR/CSS21/propidx.html
    >
    > property: 'vertical-align'
    > applies to: inline-level and 'table-cell' elements
    >
    > DIV is neither. You can set DIV to "display: table-cell;" ...but guess
    > what? You guessed it, it will not work in IE. Other options are padding
    > and line-height all a bit messy.
    >


    Well check this out then

    http://www.wpdfd.com/editorial/thebox/deadcentre4.html

    Works good in both IE and FF.
     
    richard, Sep 22, 2006
    #3
  4. richard wrote:
    >
    > "Jonathan N. Little" <> wrote in message
    > news:7f2c8$451341a7$40cba7ac$...
    >> richard wrote:
    >>> Actually, I need to know how to put the text in the middle of the
    >>> division.
    >>> As I did with tables.
    >>> Vertical-align doesn't seem to be recognized.
    >>>
    >>> www.1-small-world.com/index2.html
    >>>

    >>
    >> Look it up for yourself and see why...
    >>
    >> http://www.w3.org/TR/CSS21/propidx.html
    >>
    >> property: 'vertical-align'
    >> applies to: inline-level and 'table-cell' elements
    >>
    >> DIV is neither. You can set DIV to "display: table-cell;" ...but guess
    >> what? You guessed it, it will not work in IE. Other options are
    >> padding and line-height all a bit messy.
    >>

    >
    > Well check this out then
    >
    > http://www.wpdfd.com/editorial/thebox/deadcentre4.html
    >
    > Works good in both IE and FF.
    >
    >

    As I said a bit messy as opposed to:

    DIV.deadcenter {
    display: table-cell; text-align: center; vertical-align: middle;
    }

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Sep 22, 2006
    #4
  5. richard

    richard Guest

    "Jonathan N. Little" <> wrote in message
    news:46fb5$45135f09$40cba7ac$...
    > richard wrote:
    >>
    >> "Jonathan N. Little" <> wrote in message
    >> news:7f2c8$451341a7$40cba7ac$...
    >>> richard wrote:
    >>>> Actually, I need to know how to put the text in the middle of the
    >>>> division.
    >>>> As I did with tables.
    >>>> Vertical-align doesn't seem to be recognized.
    >>>>
    >>>> www.1-small-world.com/index2.html
    >>>>
    >>>
    >>> Look it up for yourself and see why...
    >>>
    >>> http://www.w3.org/TR/CSS21/propidx.html
    >>>
    >>> property: 'vertical-align'
    >>> applies to: inline-level and 'table-cell' elements
    >>>
    >>> DIV is neither. You can set DIV to "display: table-cell;" ...but guess
    >>> what? You guessed it, it will not work in IE. Other options are padding
    >>> and line-height all a bit messy.
    >>>

    >>
    >> Well check this out then
    >>
    >> http://www.wpdfd.com/editorial/thebox/deadcentre4.html
    >>
    >> Works good in both IE and FF.
    >>
    >>

    > As I said a bit messy as opposed to:
    >
    > DIV.deadcenter {
    > display: table-cell; text-align: center; vertical-align: middle;
    > }


    I have tried it and it does not appear to work.
    Eventually I may find something that will.
     
    richard, Sep 22, 2006
    #5
  6. richard wrote:

    > I have tried it and it does not appear to work.
    > Eventually I may find something that will.
    >


    It will *not* work in IE but *does* in "modern" browsers, that was my
    point. Therefore if you wish to accommodate Ol'IE you have to resort to
    a kludge of nested elements and playing with margins, padding and stuff....

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Sep 22, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. brucie

    Re: [css] center

    brucie, Jun 22, 2003, in forum: HTML
    Replies:
    0
    Views:
    1,419
    brucie
    Jun 22, 2003
  2. shank

    CSS and center align

    shank, Sep 29, 2003, in forum: HTML
    Replies:
    7
    Views:
    27,977
    b_imam77
    Dec 30, 2008
  3. Joshua Beall
    Replies:
    9
    Views:
    963
    Owen Jacobson
    Nov 1, 2003
  4. Quijote

    Center Box with CSS

    Quijote, May 8, 2004, in forum: HTML
    Replies:
    2
    Views:
    708
    Gnarlodious
    May 8, 2004
  5. Steve Richter

    using CSS to center text

    Steve Richter, Jul 16, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    439
    Alan Silver
    Jul 17, 2007
Loading...

Share This Page