CSS substitution for the <center> tag

Discussion in 'ASP .Net Web Controls' started by Nathan Sokalski, Jan 16, 2007.

  1. As most of us probably know, the <center> tag is deprecated. Because many
    elements and controls have an align attribute, centering them is easy
    enough. However, certain elements/controls do not (such as the ASP.NET
    Button and Label controls). For the ASP.NET label control I usually just add
    the following attributes:

    Width="100%" style="text-align:center;"

    However, this does not work for controls such as the ASP.NET Button control.
    The only solution I can think of is to nest it inside of <div
    align="center"></div> tags. However, this could add a lot of extra tags. Any
    suggestions? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
     
    Nathan Sokalski, Jan 16, 2007
    #1
    1. Advertising

  2. As I said in my original message, I have used that, but would like to have a
    way that does not involve any extra tags (in other words, I would like to do
    it using CSS). Any other ideas? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Gaurav Vaish (MasterGaurav)" <> wrote
    in message news:%...
    > <div align='center'>
    > </div>
    >
    >
    > --
    > Happy Hacking,
    > Gaurav Vaish | www.mastergaurav.com
    > www.edujini-labs.com
    > http://eduzine.edujinionline.com
    > -----------------------------------------
    >
    >
    > "Nathan Sokalski" <> wrote in message
    > news:%...
    >> As most of us probably know, the <center> tag is deprecated. Because many
    >> elements and controls have an align attribute, centering them is easy
    >> enough. However, certain elements/controls do not (such as the ASP.NET
    >> Button and Label controls). For the ASP.NET label control I usually just
    >> add the following attributes:
    >>
    >> Width="100%" style="text-align:center;"
    >>
    >> However, this does not work for controls such as the ASP.NET Button
    >> control. The only solution I can think of is to nest it inside of <div
    >> align="center"></div> tags. However, this could add a lot of extra tags.
    >> Any suggestions? Thanks.
    >> --
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/
    >>

    >
    >
     
    Nathan Sokalski, Jan 16, 2007
    #2
    1. Advertising

  3. Do you mean aligning the text inside a button? Aligning with
    style="text-align:xxx" does work for this.And the text is already centered
    by default. Do you mean something else?

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Nathan Sokalski" <> wrote in message
    news:%...
    > As most of us probably know, the <center> tag is deprecated. Because many
    > elements and controls have an align attribute, centering them is easy
    > enough. However, certain elements/controls do not (such as the ASP.NET
    > Button and Label controls). For the ASP.NET label control I usually just
    > add the following attributes:
    >
    > Width="100%" style="text-align:center;"
    >
    > However, this does not work for controls such as the ASP.NET Button
    > control. The only solution I can think of is to nest it inside of <div
    > align="center"></div> tags. However, this could add a lot of extra tags.
    > Any suggestions? Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
     
    Eliyahu Goldin, Jan 16, 2007
    #3
  4. No, I am referring to horizontally centering the button on the page (or
    within the div, td, or other tag that it is contained in). Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Eliyahu Goldin" <> wrote in
    message news:...
    > Do you mean aligning the text inside a button? Aligning with
    > style="text-align:xxx" does work for this.And the text is already centered
    > by default. Do you mean something else?
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "Nathan Sokalski" <> wrote in message
    > news:%...
    >> As most of us probably know, the <center> tag is deprecated. Because many
    >> elements and controls have an align attribute, centering them is easy
    >> enough. However, certain elements/controls do not (such as the ASP.NET
    >> Button and Label controls). For the ASP.NET label control I usually just
    >> add the following attributes:
    >>
    >> Width="100%" style="text-align:center;"
    >>
    >> However, this does not work for controls such as the ASP.NET Button
    >> control. The only solution I can think of is to nest it inside of <div
    >> align="center"></div> tags. However, this could add a lot of extra tags.
    >> Any suggestions? Thanks.
    >> --
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/
    >>

    >
    >
     
    Nathan Sokalski, Jan 16, 2007
    #4
    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. shruds
    Replies:
    1
    Views:
    870
    John C. Bollinger
    Jan 27, 2006
  2. brucie

    Re: [css] center

    brucie, Jun 22, 2003, in forum: HTML
    Replies:
    0
    Views:
    1,422
    brucie
    Jun 22, 2003
  3. Nathan Sokalski

    CSS substitution for the <center> tag

    Nathan Sokalski, Jan 16, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    334
    Przemek Ptasznik
    Jan 17, 2007
  4. Fokke Nauta
    Replies:
    20
    Views:
    12,996
    123Jim
    Jan 26, 2011
  5. Zach

    Center tag

    Zach, May 14, 2012, in forum: HTML
    Replies:
    9
    Views:
    718
    Jonathan N. Little
    May 24, 2012
Loading...

Share This Page