<DIV > vs <CENTER>

Results 1 to 4 of 4

Thread: <DIV > vs <CENTER>

  1. #1
    Join Date
    Dec 1969
    Posts
    52

    Default <DIV > vs <CENTER>

    What&#039s the differences between &#060;DIV> and &#060;CENTER>. I&#039ve tested on both, but find no difference.

  2. #2
    Nathan Pond Guest

    Default RE: <DIV > vs <CENTER>

    Simply put, &#060;DIV> is newer and has more attributes built in to it. &#060;CENTER> simply takes the text between the opening and closing tags and puts it in the center of the alloted space. &#060;DIV align=center> will do the exact same thing, but &#060;DIV> also has other attributes for other formatting and things like that. It is also a major player in DHTML. Most would advise that you start straying away from the use of &#060;center>, &#060;b>, &#060;u> and other such "old" tags and start using &#060;span> and &#060;div>. One note though, I could be wrong but I don&#039t think any browser before the 4.0 versions support &#060;div> or &#060;span>.<BR><BR>What I try to do when developing for older browsers as well as new ones is to put both in: for example<BR><BR>Welcome to:<BR><BR>&#060;DIV align=center>&#060;center>My Home Page&#060;/center>&#060;/DIV><BR><BR><BR>.....<BR><BR>it doesn&#039t hurt to have both. Hope I helped, let me know if you have any questions or are unclear on something I said.<BR><BR>Nathan Pond

  3. #3
    Join Date
    Dec 1969
    Posts
    52

    Default RE: <DIV > vs <CENTER>

    Thank you for the reply!<BR><BR>As you said &#060;div align="center"> is the same as &#060;center> and &#060;div> may not be supported by browser with older version, then why you still use &#060;div> together with &#060;center>?

  4. #4
    Nathan Pond Guest

    Default RE: <DIV > vs <CENTER>

    Because, in theory the &#060;center> tag will become obsolete in the future. And more browsers will support the &#060;DIV> tag as time goes on. Consider this:<BR><BR>&#060;DIV align=center class=myClass>My text!&#060;/DIV><BR><BR>now that will center my text and give it the style of my css class "myClass." Let&#039s say that class makes the text size 5, bold, underline, and red. To get the same effect with plain html you would need:<BR><BR>&#060;center>&#060;font size=5 color=red>&#060;b>&#060;u>My Text!&#060;/u>&#060;/b>&#060;/font>&#060;/center><BR><BR>This is what tags like &#060;DIV> and &#060;SPAN> are trying to do, simplify HTML. So you want to try to use them whenever possible, although you don&#039t want to forget about older versions so also throw the &#060;center> in for now. It will be easier to go back later and delete all &#060;center> tags than to re-write your html.<BR><BR>Hope I cleared things up a little, this is just a simple example, I didn&#039t even touch on the DHTML aspect which gives &#060;DIV> even more of an advantage. Let me know if you have any more questions.<BR><BR>Nathan


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •