1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

text-align in netscape?

Discussion in 'CSS' started by mahmood, May 23, 2006.

  1. #1
    What do I use to get netscape put the second div at the center of the first one in this code:
    <div style='width:900px;text-align:center;'>
    	<div style='width:500px;'>one two three
    	</div>
    </div>
    PHP:
    Seems that netscape ignors text-align:center.
     
    mahmood, May 23, 2006 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    {text-align: center;} aligns inline components, eg., um, text, not block level elements. IE in quirks mode exhibits the buggy behavior you seek. Put IE in standards mode, and it will get it right, too.
    
    <div style='width:900px; margin: 0 auto;'>
      <div style='width:500px;'>
        <p>one two three</p>
      </div>
    </div> 
    Code (markup):
    You will need to use a complete and proper DTD to trigger standards mode in IE. If you've been coding for IE, look for breakage to occur when switched to following standards.

    There are some misguided souls who will suggest
    
    <div style='width:900px;text-align:center; margin: 0 auto;'>
      <div style='width:500px; text-align: left;'>one two three
      </div>
    </div> 
    Code (markup):
    to allow the funky behavior, but using a mode whereby IE follows even fewer of the rules than normal and many of those wrongly is just asking for compatibility headaches.

    cheers,

    gary
     
    kk5st, May 23, 2006 IP
    mahmood likes this.