It appears you have not yet registered with our community. To register please click here...


Centering divisions without align

This is a discussion on Centering divisions without align within the HTML & CSS forums. Topic: Lets say i have a division Code: <div style="width: 700px; text-align: left;">hi!</...


Reply
 
Postbit Seperator LinkBack Thread Tools Postbit Seperator Display Modes
Old 02-03-2007, 08:32 PM   #1 (permalink)
 
Status: Junior Member
Join Date: Jan 2007
Location: Rochester, NY
Posts: 29
Trader Rating: (0)
ahamilton9 is on a distinguished road
Send a message via AIM to ahamilton9 Send a message via Yahoo to ahamilton9
TD$: 0.00
Donate
Default Centering divisions without align
Lets say i have a division
Code:
<div style="width: 700px; text-align: left;">hi!</div>
How exactly do I center the entire division relative to the page as a whole and not just the text as relative to the division without using align="center" since it has been deprecated. Any help would be appreciated, thanks in advance.

Edit: margin: auto; works for Firefox but doesn't seem to do anything in IE7.
__________________
This signature intentionally left blank.

Last edited by ahamilton9; 02-03-2007 at 09:00 PM..
ahamilton9 is offline   Reply With Quote
Old 02-05-2007, 11:04 AM   #2 (permalink)
 
Status: Junior Member
Join Date: Feb 2007
Posts: 13
Trader Rating: (0)
craig is on a distinguished road
TD$: 0.00
Donate
Default Re: Centering divisions without align
add
Code:
text-align: center;
to your "body" styles.

and try using
Code:
margin: 0 auto;
instead of margin:auto;
__________________
/* hide the tables */
table { visibility: hidden; } /* gone! */


www.cycadelic.org
craig is offline   Reply With Quote
Old 02-05-2007, 09:46 PM   #3 (permalink)
 
Status: Junior Member
Join Date: Jan 2007
Location: Rochester, NY
Posts: 29
Trader Rating: (0)
ahamilton9 is on a distinguished road
Send a message via AIM to ahamilton9 Send a message via Yahoo to ahamilton9
TD$: 0.00
Donate
Default Re: Centering divisions without align
Neither work. I'll stick with align="center" but I seriously think whomever is specifically in charge of XHTML and CSS standards via W3C or such needs to step down. A simple "element-align: ~~~;" or general "align: ~~~;" that would apply to all elements would solve so many problems, including the misuse of float... you can't deprecate something without putting a complete alternative out there.
__________________
This signature intentionally left blank.
ahamilton9 is offline   Reply With Quote
Old 02-06-2007, 10:07 AM   #4 (permalink)
 
Status: Junior Member
Join Date: Feb 2007
Posts: 13
Trader Rating: (0)
craig is on a distinguished road
TD$: 0.00
Donate
Default Re: Centering divisions without align
Use this as your CSS

Code:
<style>

* {
	margin: 0;
	padding: 0;
}

body {
	text-align: center;
}

div#main {
	margin: 0 auto;
	text-align: left;
        width: 700px;
}
</style>
and then <div id="main"></div> will be centered.

This works on IE, Firefox and Opera
__________________
/* hide the tables */
table { visibility: hidden; } /* gone! */


www.cycadelic.org
craig is offline   Reply With Quote
Old 02-12-2007, 06:50 PM   #5 (permalink)
 
Status: Junior Member
Join Date: Feb 2007
Posts: 4
Trader Rating: (0)
Kirth is on a distinguished road
TD$: 0.00
Donate
Default Re: Centering divisions without align
I'm not sure but I think this is the easiest:
Code:
<center> Centar this txt baby! :D</center>
.
Ofcourse if only works for the txt witin the <center></center> tags,

If you want to get all the txt you made centerd,
CSS is the only way out .
Code:
<style type="text/css">
	p {
		text-align: center;
	}
</style>
.
Kirth is offline   Reply With Quote
Table Bottom LeftTable BottomTable Bottom Right
Reply


Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Free Wordpress Theme – Tranquil Divisions voidix Web Design Resources 0 08-24-2007 01:08 AM
Centering Text in PHP.GD Images Retire at 21 Coding Tutorials 0 12-10-2006 01:27 PM


Home | Site Map | Contact | Archive | Top

 

Copyright © 2007 - 2010 iTalkWebs Network

Search Engine Optimization by vBSEO 3.1.0