Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why doesn't DIV FIELDSET center on page?

Status
Not open for further replies.

gnubie

Programmer
Apr 16, 2002
103
US
I've been using <DIV ALIGN=&quot;CENTER&quot;> to center blocks of text. But in IE 6 and N 6, the <FIELDSET> isn't centered on the page as expected. Can anyone shed any light on this embaffleating behavior?

A FIELDSET comparison using <DIV ALIGN=&quot;CENTER&quot;> and <CENTER> methods appears below:


Code:
<html>
<head>
  <title>FIELDSET Center Test</title>
</head>

<body>
<div align=&quot;center&quot; style=&quot;width: 75%&quot; >
  <fieldset title=&quot;FIELDSET Center Test #1&quot;>
  <legend class=&quot;hdr2&quot; align=&quot;center&quot;>FIELDSET Center Test #1</legend>
  This version uses <DIV ALIGN=&quot;CENTER&quot;><br>
  Why isn't the WHOLE FIELDSET centered?
  </fieldset>
</div>

<center>
<div style=&quot;width: 75%&quot;>
  <fieldset title=&quot;FIELDSET Center Test #2&quot;>
  <legend class=&quot;hdr2&quot; align=&quot;center&quot;>FIELDSET Center Test #2</legend>
  This version uses <CENTER> and is centered correctly.<br>
  This is what I want.
  </fieldset>
</div>
</center>

</body>
</html>

Thanks,
Gnubie


 
Move the &quot;width:75%&quot; from the <div> to the <fieldset> like this:

<div align=&quot;center&quot;>
<fieldset title=&quot;FIELDSET Center Test #1&quot; style=&quot;width: 75%&quot;>
<legend class=&quot;hdr2&quot; align=&quot;center&quot;>FIELDSET Center Test #1</legend>
This version uses ->DIV ALIGN=&quot;CENTER&quot;<-<br>
Why isn't the WHOLE FIELDSET centered?
</fieldset>
</div>

Hope this helps,
Erik

<-- My sport: Boomerang throwing !!
!! Many Happy Returns !! -->
 
A little off topic but the fieldset tag is new to me what's the advantage of using it or Div. Sorry for my ignorance. All help is appreciated.
 
Boomerang: Thank you!

GlenMac: a picture is worth a 250 4 byte words. Copy and paste the code snippit above into an HTML doc and you'll see in an instant why it is used.

Gnubie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top