Deprecated Code – Why You Should Avoid It

If you’re perusing one of my articles on blog coding, for instance Centering Complex and Multiple Objects, and you follow my advice to read the W3 Schools tutorials for further advice, you’ll find a lot to read. They give you good canonical definitions of each HTML tag, and interactive exercises so you can see what each one actually does.

If you’re reading about the <center> tag, you’ll note the advice

The center element was deprecated in HTML 4.01.
The center element is not supported in XHTML 1.0 Strict DTD.

If you’re not blocking popups from http://www.w3schools.com, you’ll note a popup window advising you that

A deprecated element or attribute is one that has been outdated.
Deprecated elements may become obsolete in the future, but browsers should continue to support deprecated elements for backward compatibility.

In other words, you can keep using <center> … </center> right now, but one day in the future, it may stop working. No guarantee when, either.

In HTML, an element is deprecated only when there is a replacement for it. In this case, this is a good replacement. The <center> … </center> tags are known to display differently in Firefox and Internet Explorer.

For <center> … </center>, you’re advised

Use CSS styles to center text!

I use

<span style=”text-align:center;”> … </span>

to center text, for instance. You can use the

<span> … </span>

pair within a paragraph, or wherever else convenient. And if you want to center graphic objects, or multiple text objects, relative to each other, you can use nested tables.

Advertisements

One Response to “Deprecated Code – Why You Should Avoid It”

  1. Mary Says:

    Good to know! Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: