Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 07-05-2007, 06:20 AM   PM User | #1
SMC
New Coder

 
Join Date: Jun 2007
Location: Orlando, FL
Posts: 60
Thanks: 5
Thanked 2 Times in 2 Posts
SMC can only hope to improve
XHTML compliant div align substitute [SOLVED]

Hello everyone,

Basically I have a perfect working DIV layer when it has <div align="center"></div>. Unfortunatly, that isn't XHTML compatible. I'm looking for an alternative I can use to get that green rectangle back.

Heres what I've got right now:

Code:
<div id="results_div" style="display: none; float: center; text-align: center; margin: auto;">
		<div class="rectangle gray register_error">
			<span id="results_span"></span>
		</div>
	</div>
The initial div is right I'm trying to get centered, unfortunatly everything shoots off to the left. I thank you for any help you can offer!
SMC is offline   Reply With Quote
Old 07-05-2007, 07:01 AM   PM User | #2
VIPStephan
Senior Coder

 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 3,876
Thanks: 3
Thanked 322 Times in 308 Posts
VIPStephan has a spectacular aura aboutVIPStephan has a spectacular aura about
To center the inline-level content of a block-level element use text-align: center;
To center a block-level element itself apply a width and use margin: auto; (important is that left and right margins are set to auto, top and bottom can be any value).

There is no value center for the float property, only left or right.

Oh and I encourage you to use semantic HTML and this includes class names and IDs with functional names, i.e. names that reflect the function of the element, not the (alleged) look. <div class="gray"> means nothing if you intend to change the color to blue at some time (same goes for “rectangle”) whereas <div class="results"> would be the correct way.
__________________
Don’t click this link!

Last edited by VIPStephan; 07-05-2007 at 07:10 AM..
VIPStephan is offline   Reply With Quote
Old 07-05-2007, 03:15 PM   PM User | #3
SMC
New Coder

 
Join Date: Jun 2007
Location: Orlando, FL
Posts: 60
Thanks: 5
Thanked 2 Times in 2 Posts
SMC can only hope to improve
Worked like a charm, thanks!
SMC is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:36 PM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.