User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 362,353 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,572 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 57249 | Replies: 6
Reply
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,868
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 32
Solved Threads: 107
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

div align=center

  #1  
Jul 18th, 2004
What is the difference between <div align="center"> and <div style="text-align:center"> aside from the obvious difference that the latter is CSS?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2004
Location: Brisbane
Posts: 630
Reputation: Slade has a spectacular aura about Slade has a spectacular aura about 
Rep Power: 7
Solved Threads: 6
Slade's Avatar
Slade Slade is offline Offline
Practically a Master Poster

Re: div align=center

  #2  
Jul 18th, 2004
well, I've experimented with it a little before and validated it, aligning a div is not valid strict xhtml 1.0 anyways heh . Other than that I don't know, I know I had different results when I used the div align but none that would make sense. E.g. I set the text-align in my stylesheet to right, this worked but I set the div align to bottom, nothing happened with the text but an image I had in the same div was aligned to the top . Other than that I'm not sure, I think that text-align only applies to text.

once again, my opinion is much ado about nothing.
Formerly known as Slade.
Reply With Quote  
Join Date: Sep 2004
Location: Saline, MI
Posts: 9
Reputation: ZWheel is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ZWheel's Avatar
ZWheel ZWheel is offline Offline
Newbie Poster

Re: div align=center

  #3  
Sep 19th, 2004
Well, in that example there is no difference, it's just part of a push away from using html attributes for style and towards css.

IF I understand right the current movement is towards having the HTML (to be replaced by XML) describing only the actual content. Then how it is represented on the screen would be described in the css. This way if you only need one data file when using the same content in different ways ex: display on a computer monitor/cell phone/pda/import it into a database, etc....

Of course this only applies when you use an external stylesheet, not when you have the style embedded right in to the tag. I suspect this will one day be depricated as well and is only allowable now to make it easier for people to transition from the old way to the new.
Reply With Quote  
Join Date: Nov 2003
Location: California
Posts: 199
Reputation: rixius is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 1
rixius rixius is offline Offline
Junior Poster

Re: div align=center

  #4  
Sep 20th, 2004
I don't think align="" is valid XHTML 1.0 coding. style="text-align: " is, however.
Reply With Quote  
Join Date: Jul 2007
Posts: 1
Reputation: majj is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
majj majj is offline Offline
Newbie Poster

Question Re: div align=center

  #5  
Jul 11th, 2007
text-align CSS property applies only to the content and not the container. float property helps align the container but has no 'center' attribute. Many have suggested work around methods, which do not work uniformly in all browsers. Perhaps a combination attributes relating to margin, position, and container width could provide a way out. Will appreciate suggestions that address this issue
Reply With Quote  
Join Date: Jun 2006
Posts: 5
Reputation: Mrtony is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Mrtony Mrtony is offline Offline
Newbie Poster

Re: div align=center

  #6  
Jul 11th, 2007
setting a divs margin-left and margin-right to auto is the correct syntax to make a float center to its predecessors if you set its width; the same will work for top and bottom centering with the height set.
Reply With Quote  
Join Date: Jan 2007
Posts: 2,361
Reputation: MidiMagic is on a distinguished road 
Rep Power: 6
Solved Threads: 89
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Posting Maven

Re: div align=center

  #7  
Jul 13th, 2007
align= is deprecated.

And the W3C clowns gave us no good way to center images in nondeprecated ways. They are thinking book and newspaper layout, where images are never centered.

So I do this:
<style type="text/css">
.cenx {text-align: center;}
.ceni {clear: both;}
.bxfix {margin: none; border: none; padding: none;}
img {padding: 12px;}
body {padding: 5%;}
</style>

Then for the image itself:

<div class="bxfix cenx">
 <img src="mine.jpg" alt="my mine" class="ceni" />
</div>
Last edited by MidiMagic : Jul 13th, 2007 at 5:09 am.
Daylight-saving time uses more gasoline
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 3 (0 members and 3 guests)

 

DaniWeb HTML and CSS Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the HTML and CSS Forum

All times are GMT -4. The time now is 11:30 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC