View Full Version : Centering div with HTML 4.01 Transitional
To center divs on a page, I usually use:
margin-right: auto;
margin-left: auto;
but this seems to only with HTML 1.0 transitional. Can you make it work with 4, or maybe just use 1.0 all the time or maye something else altogether....?
I had a problem centering iframes recently using the code you posted. The solution was to give the item I was trying to center a fixed width instead of a percentage.
I had a problem centering iframes recently using the code you posted. The solution was to give the item I was trying to center a fixed width instead of a percentage.
iframes behave in strange ways sometimes for me, and I also do a fixed width usually wider than the iframe and add this:
text-align: center;
to the div's properties.
But I was referring to centering the actual div, not the content within the div. Seems to behave differently in HTML 1.0 and HTML 4.0
bluebrit
2010-05-25, 12:47 PM
the <center> tag was deprecated in HTML 4.0 so try using this
<div style="text-align: center;">
Yeah it was the content within the div that I was talking about.
Despite using text-align: center; my iframe still wasn't centering. I did some Googling and found the suggestion to give my iframe a fixed width instead of a percent and it fixed it.
I still struggle with css but thought that maybe it would work with your issue too.
Just a guess but maybe
display:block;
margin-right:auto;
margin-left:auto;
Nymph
2010-05-25, 12:56 PM
using
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
I use
<div align="center"></div>
of course you can use styling to the div tag too
Maj. Stress
2010-05-26, 02:01 PM
the <center> tag was deprecated in HTML 4.0 so try using this
<div style="text-align: center;">
It was? I can still validate pages at w3.org using it.
link (http://validator.w3.org/check?uri=http%3A%2F%2Fslut-fest.com%2Fgay-twinks-fuck%2F&charset=(detect+automatically)&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.767)
http://slut-fest.com/gay-twinks-fuck/
bluebrit
2010-05-26, 04:32 PM
It was? I can still validate pages at w3.org using it.
link (http://validator.w3.org/check?uri=http%3A%2F%2Fslut-fest.com%2Fgay-twinks-fuck%2F&charset=(detect+automatically)&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.767)
It has been deprecated in 4.01 transitional and frameset, take a look at the table in their own link below.
http://www.w3schools.com/tags/default.asp
Maj. Stress
2010-05-26, 10:43 PM
It has been deprecated in 4.01 transitional and frameset, take a look at the table in their own link below.
http://www.w3schools.com/tags/default.asp
Interesting that the validator does not flag it. I've had it flag the div align="center" before. |crazy|
Maj. Stress
2010-05-26, 10:46 PM
Yeah it was the content within the div that I was talking about.
Despite using text-align: center; my iframe still wasn't centering. I did some Googling and found the suggestion to give my iframe a fixed width instead of a percent and it fixed it.
I still struggle with css but thought that maybe it would work with your issue too.
Just a guess but maybe
display:block;
margin-right:auto;
margin-left:auto;
I haven't tested it but that looks like it should work.
vBulletin® v3.8.1, Copyright ©2000-2026, Jelsoft Enterprises Ltd.