954,595 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

div align=center

What is the difference between and aside from the obvious difference that the latter is CSS?

cscgal
The Queen of DaniWeb
Administrator
19,436 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
 

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.

Slade
Practically a Master Poster
633 posts since Mar 2004
Reputation Points: 115
Solved Threads: 7
 

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.

ZWheel
Newbie Poster
12 posts since Sep 2004
Reputation Points: 13
Solved Threads: 0
 

I don't think align="" is valid XHTML 1.0 coding. style="text-align: " is, however.

rixius
Posting Whiz in Training
233 posts since Nov 2003
Reputation Points: 12
Solved Threads: 3
 

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

majj
Newbie Poster
1 post since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

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.

Mrtony
Newbie Poster
5 posts since Jun 2006
Reputation Points: 10
Solved Threads: 0
 

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>
MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
 

Just make a simple class

After that just put id="header" in your div.

ssrawat
Newbie Poster
1 post since Feb 2011
Reputation Points: 11
Solved Threads: 0
 

Hi,

<div align="center">



align the div to the center position

<div style="text-align:center">

align the content of the div to center position.

Bestwebdesign
Newbie Poster
8 posts since Jan 2011
Reputation Points: 10
Solved Threads: 1
 

Both would perform the same task. When using ..., you are fulfilling your objective by using HTML only but in case of .. you are mainly relying on CSS to make the content center aligned. Other than that, there is no difference between the two, I think

johnsteve.bravo
Light Poster
39 posts since Jan 2011
Reputation Points: 11
Solved Threads: 6
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You