How do I center this.

Discussion in 'HTML & Website Design' started by Smithers, Jul 30, 2007.

  1. #1
    I wanna center that how do I do it HTML <center> tags screws it up.
     
    Smithers, Jul 30, 2007 IP
  2. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What does the HTML code output for that look like?
     
    Dan Schulz, Jul 30, 2007 IP
  3. Corey Bryant

    Corey Bryant Texan at Heart

    Messages:
    1,126
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Corey Bryant, Jul 30, 2007 IP
  4. Arson

    Arson Well-Known Member

    Messages:
    622
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    120
    #4
    you could either put align="center" in the table code right after cellspacing="0", or you could put
    <center>

    </center>

    around the whole script.
     
    Arson, Jul 30, 2007 IP
  5. Arson

    Arson Well-Known Member

    Messages:
    622
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Oh or <div align=center> </div> (basically the same thing as <center></center>)
     
    Arson, Jul 30, 2007 IP
  6. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Not recommended - they may work in Transitional DOCTYPEs, but they're deprecated (rendered obsolete, and slated for removal) in Strict DOCTYPEs.
     
    Dan Schulz, Jul 30, 2007 IP
  7. WACMan

    WACMan Peon

    Messages:
    253
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Why not wrap the whole template in a <div> tag and assign it a class and use CSS to center it?
     
    WACMan, Jul 30, 2007 IP
  8. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #8
    At which point I'd just assign a width to the BODY and set its margins to 0 auto;
     
    Dan Schulz, Jul 30, 2007 IP
  9. darnsitebetter

    darnsitebetter Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Or try using a wrapper div and setting the width and margins as Dan describes. Worth checking this in a variety of browsers to ensure consistent behavior.
     
    darnsitebetter, Jul 30, 2007 IP
  10. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Don't need a wrapper DIV unless you're going to support IE 5.x (at which point you might as well set text-align: center; on the body selector and then text-align: left; on the wrapper).
     
    Dan Schulz, Jul 30, 2007 IP
  11. webdesignerindia

    webdesignerindia Peon

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    before this div tag

    <div class="post" id="post-<?php the_ID(); ?>">

    put another div tag like this

    <div id="align">
    <div class="post" id="post-<?php the_ID(); ?>">

    now for id="align "

    put this style on the stylesheet file !!

    #align {
    margin:0px auto;
    }

    It will be centered....!!


    regards,
    website designer
     
    webdesignerindia, Jul 31, 2007 IP
  12. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #12
    can do one better - add this to your CSS

    .post,
    .navigation {
    margin:0 auto;
    }

    That's it. You have two outermost containers (at least before the else - AFTER already looks to be centered) so just apply the centering margins (and your widths if not present) to those two and you should be good to go.

    Though... do you mean center the boxes, or center the content inside their boxes? If the latter, you'd want:

    .post td {
    text-align:center;
    }

    But I don't think that's what you are asking for.
     
    deathshadow, Jul 31, 2007 IP