By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,712 Members | 1,344 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,712 IT Pros & Developers. It's quick & easy.

Replacement for <div align="center">

P: n/a
Hello,

When centering a block of HTML, in the past, I've always used:

<div align="center"> ... </div>

However, in VS 2005, I get the following warning:

"Validation (XHTML 1.0 Transitional): Attribute 'align' is considered
outdated. A newer construct is recommended."

What is the newer construct I should use?

Thanks!
Ben
Nov 30 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
<CENTER>...</CENTER>


"Ben Amada" <be*@REpoMOweVErpick.com> wrote in message
news:u$**************@TK2MSFTNGP14.phx.gbl...
Hello,

When centering a block of HTML, in the past, I've always used:

<div align="center"> ... </div>

However, in VS 2005, I get the following warning:

"Validation (XHTML 1.0 Transitional): Attribute 'align' is considered
outdated. A newer construct is recommended."

What is the newer construct I should use?

Thanks!
Ben

Nov 30 '05 #2

P: n/a
Scott M. wrote:
<CENTER>...</CENTER>


Hi Scott,

Are you sure?? Hasn't <center> been deprecated for years now?

Ben
Nov 30 '05 #3

P: n/a
Actually, W3C recommands you to use CSS style(i.e.: style="TEXT-ALIGN:
center") instead.

"Ben Amada" <be*@REpoMOweVErpick.com> glsD:u$**************@TK2MSFTNGP14.phx.g bl...
Hello,

When centering a block of HTML, in the past, I've always used:

<div align="center"> ... </div>

However, in VS 2005, I get the following warning:

"Validation (XHTML 1.0 Transitional): Attribute 'align' is considered
outdated. A newer construct is recommended."

What is the newer construct I should use?

Thanks!
Ben

Nov 30 '05 #4

P: n/a
Lau Lei Cheong wrote:
Actually, W3C recommands you to use CSS style(i.e.: style="TEXT-ALIGN:
center") instead.


Hi,

Thanks for the tip. Actually, I did try using the text-align style once,
however I ran into a problem where inside the <div> tag, I inserted a
<table> and the table correctly centers in IE, however in Firefox, the table
renders on the left side of the browser. Basically the HTML looks like:

<div style="text-align:center">
<h1>Header</h1>
<table> ... </table>
</div>

The contents of <h1> correctly centers in Firefox, however the entire table
is left-justified.

Any ideas on how to resolve this?

Thanks,
Ben
Nov 30 '05 #5

P: n/a
Ben Amada <be*@REpoMOweVErpick.com> ha scritto:
Any ideas on how to resolve this?

Thanks,
Ben


Try this code:

<div style="text-align:center;">
<h1>Header</h1>
<table style="margin-right: auto; margin-left: auto;">
<tr><td>r1</td></tr>
<tr><td>r2</td></tr>
</table>
</div>

--
AZ [Microsoft - .NET MVP]
Mia Home page: http://ciclismo.sitiasp.it
Asp.Net community: http://www.aspitalia.com
Il mio blog: http://blogs.aspitalia.com/az
--
AZ [Microsoft - .NET MVP]
Mia Home page: http://ciclismo.sitiasp.it
Asp.Net community: http://www.aspitalia.com
Il mio blog: http://blogs.aspitalia.com/az
Nov 30 '05 #6

P: n/a
Yes it has. And so has <FONT> and many other tags, but we use them every
day because they are part of the "HTML 4.01 Transitional" DTD. This is what
"Transitional" means, it means that you can use deprecated code AND CSS. If
you were using "HTML 4.01 Strict", you couldn't do that, but most people use
Transitional because support for the deprecated tags is still very
widespread.

"Ben Amada" <be*@REpoMOweVErpick.com> wrote in message
news:eP*************@TK2MSFTNGP09.phx.gbl...
Scott M. wrote:
<CENTER>...</CENTER>


Hi Scott,

Are you sure?? Hasn't <center> been deprecated for years now?

Ben

Nov 30 '05 #7

P: n/a
Well, Scott, let me remind you that "deprecated" is a word which indicates a
kind of warning, if you will, that something is not going to last. The word
"transitional" indicates that something is being supported during a
transition phase from one set of standards to another, and a transitional
phase lasts only as long as the transition.

Yes, browsers may support this tag (and other deprected tags and elements)
for some years to come, but eventually they will not, and in the meantime,
being deprecated, it (and other deprecated tags) may not work as well over
time, as they come into (possible) conflict with emerging standards.

Bearing this in mind, and being a developer who doesn't want to overburden
himself in the future, while I am not going back over everything I've
created to date and updating it, neither do I want to have to do so all at
one painful whack in the future. So, my personal strategy is to work with
the new standards when I am doing new work, and to avoid deprecated
standards as much as possible. Older work I leave as is, unless I have to do
some maintenance or other upgrade type work on it, in which case I may, if
convenient, do a bit of standards upgrading as well.

Of course, this is not something I am touting as "the right way" or "the
only way" to do things, but I hope you may find it food for thought.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"Scott M." <s-***@nospam.nospam> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
Yes it has. And so has <FONT> and many other tags, but we use them every
day because they are part of the "HTML 4.01 Transitional" DTD. This is
what "Transitional" means, it means that you can use deprecated code AND
CSS. If you were using "HTML 4.01 Strict", you couldn't do that, but most
people use Transitional because support for the deprecated tags is still
very widespread.

"Ben Amada" <be*@REpoMOweVErpick.com> wrote in message
news:eP*************@TK2MSFTNGP09.phx.gbl...
Scott M. wrote:
<CENTER>...</CENTER>


Hi Scott,

Are you sure?? Hasn't <center> been deprecated for years now?

Ben


Nov 30 '05 #8

P: n/a
Yes Kevin, I'm aware of all that. My feeling is that the bulk of the
deprecated tags have been that way for nearly a decade. I can't forsee any
time in the future where an HTML parser won't understand <CENTER> and
<FONT>, it's just not going to happen because of the 100's of millions of
pages that have these tags on them.

This is why we have the choice to use Transitional or Strict. I guess what
I'm saying is that I believe Transitional will be around forever.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Ob**************@TK2MSFTNGP10.phx.gbl...
Well, Scott, let me remind you that "deprecated" is a word which indicates
a kind of warning, if you will, that something is not going to last. The
word "transitional" indicates that something is being supported during a
transition phase from one set of standards to another, and a transitional
phase lasts only as long as the transition.

Yes, browsers may support this tag (and other deprected tags and elements)
for some years to come, but eventually they will not, and in the meantime,
being deprecated, it (and other deprecated tags) may not work as well over
time, as they come into (possible) conflict with emerging standards.

Bearing this in mind, and being a developer who doesn't want to overburden
himself in the future, while I am not going back over everything I've
created to date and updating it, neither do I want to have to do so all at
one painful whack in the future. So, my personal strategy is to work with
the new standards when I am doing new work, and to avoid deprecated
standards as much as possible. Older work I leave as is, unless I have to
do some maintenance or other upgrade type work on it, in which case I may,
if convenient, do a bit of standards upgrading as well.

Of course, this is not something I am touting as "the right way" or "the
only way" to do things, but I hope you may find it food for thought.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"Scott M." <s-***@nospam.nospam> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
Yes it has. And so has <FONT> and many other tags, but we use them every
day because they are part of the "HTML 4.01 Transitional" DTD. This is
what "Transitional" means, it means that you can use deprecated code AND
CSS. If you were using "HTML 4.01 Strict", you couldn't do that, but
most people use Transitional because support for the deprecated tags is
still very widespread.

"Ben Amada" <be*@REpoMOweVErpick.com> wrote in message
news:eP*************@TK2MSFTNGP09.phx.gbl...
Scott M. wrote:

<CENTER>...</CENTER>

Hi Scott,

Are you sure?? Hasn't <center> been deprecated for years now?

Ben



Nov 30 '05 #9

P: n/a
Sure Scott. Seems Bill Gates once said that a computer would never need more
than a megabyte of RAM, now that I think of it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"Scott M." <s-***@nospam.nospam> wrote in message
news:ut*************@tk2msftngp13.phx.gbl...
Yes Kevin, I'm aware of all that. My feeling is that the bulk of the
deprecated tags have been that way for nearly a decade. I can't forsee
any time in the future where an HTML parser won't understand <CENTER> and
<FONT>, it's just not going to happen because of the 100's of millions of
pages that have these tags on them.

This is why we have the choice to use Transitional or Strict. I guess
what I'm saying is that I believe Transitional will be around forever.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Ob**************@TK2MSFTNGP10.phx.gbl...
Well, Scott, let me remind you that "deprecated" is a word which
indicates a kind of warning, if you will, that something is not going to
last. The word "transitional" indicates that something is being supported
during a transition phase from one set of standards to another, and a
transitional phase lasts only as long as the transition.

Yes, browsers may support this tag (and other deprected tags and
elements) for some years to come, but eventually they will not, and in
the meantime, being deprecated, it (and other deprecated tags) may not
work as well over time, as they come into (possible) conflict with
emerging standards.

Bearing this in mind, and being a developer who doesn't want to
overburden himself in the future, while I am not going back over
everything I've created to date and updating it, neither do I want to
have to do so all at one painful whack in the future. So, my personal
strategy is to work with the new standards when I am doing new work, and
to avoid deprecated standards as much as possible. Older work I leave as
is, unless I have to do some maintenance or other upgrade type work on
it, in which case I may, if convenient, do a bit of standards upgrading
as well.

Of course, this is not something I am touting as "the right way" or "the
only way" to do things, but I hope you may find it food for thought.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"Scott M." <s-***@nospam.nospam> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
Yes it has. And so has <FONT> and many other tags, but we use them
every day because they are part of the "HTML 4.01 Transitional" DTD.
This is what "Transitional" means, it means that you can use deprecated
code AND CSS. If you were using "HTML 4.01 Strict", you couldn't do
that, but most people use Transitional because support for the
deprecated tags is still very widespread.

"Ben Amada" <be*@REpoMOweVErpick.com> wrote in message
news:eP*************@TK2MSFTNGP09.phx.gbl...
Scott M. wrote:

> <CENTER>...</CENTER>

Hi Scott,

Are you sure?? Hasn't <center> been deprecated for years now?

Ben



Nov 30 '05 #10

P: n/a
....And, host programming will be a thing of the past in 5 years (10 years
ago).

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:u5*************@TK2MSFTNGP09.phx.gbl...
Sure Scott. Seems Bill Gates once said that a computer would never need
more than a megabyte of RAM, now that I think of it.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"Scott M." <s-***@nospam.nospam> wrote in message
news:ut*************@tk2msftngp13.phx.gbl...
Yes Kevin, I'm aware of all that. My feeling is that the bulk of the
deprecated tags have been that way for nearly a decade. I can't forsee
any time in the future where an HTML parser won't understand <CENTER> and
<FONT>, it's just not going to happen because of the 100's of millions of
pages that have these tags on them.

This is why we have the choice to use Transitional or Strict. I guess
what I'm saying is that I believe Transitional will be around forever.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Ob**************@TK2MSFTNGP10.phx.gbl...
Well, Scott, let me remind you that "deprecated" is a word which
indicates a kind of warning, if you will, that something is not going to
last. The word "transitional" indicates that something is being
supported during a transition phase from one set of standards to
another, and a transitional phase lasts only as long as the transition.

Yes, browsers may support this tag (and other deprected tags and
elements) for some years to come, but eventually they will not, and in
the meantime, being deprecated, it (and other deprecated tags) may not
work as well over time, as they come into (possible) conflict with
emerging standards.

Bearing this in mind, and being a developer who doesn't want to
overburden himself in the future, while I am not going back over
everything I've created to date and updating it, neither do I want to
have to do so all at one painful whack in the future. So, my personal
strategy is to work with the new standards when I am doing new work, and
to avoid deprecated standards as much as possible. Older work I leave as
is, unless I have to do some maintenance or other upgrade type work on
it, in which case I may, if convenient, do a bit of standards upgrading
as well.

Of course, this is not something I am touting as "the right way" or "the
only way" to do things, but I hope you may find it food for thought.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"Scott M." <s-***@nospam.nospam> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
Yes it has. And so has <FONT> and many other tags, but we use them
every day because they are part of the "HTML 4.01 Transitional" DTD.
This is what "Transitional" means, it means that you can use deprecated
code AND CSS. If you were using "HTML 4.01 Strict", you couldn't do
that, but most people use Transitional because support for the
deprecated tags is still very widespread.

"Ben Amada" <be*@REpoMOweVErpick.com> wrote in message
news:eP*************@TK2MSFTNGP09.phx.gbl...
> Scott M. wrote:
>
>> <CENTER>...</CENTER>
>
> Hi Scott,
>
> Are you sure?? Hasn't <center> been deprecated for years now?
>
> Ben
>



Dec 1 '05 #11

P: n/a
Andrea Zani wrote:
Try this code:

<div style="text-align:center;">
<h1>Header</h1>
<table style="margin-right: auto; margin-left: auto;">
<tr><td>r1</td></tr>
<tr><td>r2</td></tr>
</table>
</div>


Hi Andrea,

That works great :)

Thank you,
Ben
Dec 1 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.