Deprecated HTML

I would like to mention something about deprecated HTML as I feel compelled to do so because I used some deprecated HTML in my book for the purpose of simplicity in illustrating some points. I used deprecated HTML tags and attributes in the markup language in Chapter 8 where I emphasized the practice of keeping the markup completely separated from the PHP code in my instruction of how to build a custom model-view-controller application.

In the book I show how to build a MySQL database driven Restaurant Menu Management application as a custom MVC app. In the downloadable code for that application I did however replace the deprecated markup with HTML templates that are written according to HTML5 standards and include proper CSS.

Deprecated simply means that an old attribute or tag is not approved of although it still works in newer browsers. It’s not obsolete, it’s just old and there is something “better” that the browsers prefer you use instead.

For example:

Deprecated:

<HTML>
<HEAD>
<TITLE>Deprecated</TITLE>
</HEAD>
<BODY>
<CENTER>
<FONT SIZE="10" COLOR="GREEN">This is deprecated</FONT>
</CENTER>
</BODY>
</HTML>

Non-Deprecated:

<html>
<head>
<title>Not Deprecated</title>

<style type="text/css">
 div.c1 {color: green; font-size: 70%; text-align: center}
</style>
</head>
<body>
<div>This is not deprecated</div>
</body>
</html>

Having deprecated tags and attributes in your markup can cause issues with search engine indexing but the main reason it is best practice to replace deprecated tags and attributes is because they will not be supported in the future.  HTML is designated to only provide structure, not formatting and presentation.  Making these deprecated tags and attributes obsolete thus meets the goal of separating presentation from structure. In a pure CSS environment, basic HTML tags define paragraphs, lists, headers, etc. and CSS definitions tell the browser how to display them.

Here's a tip, if you have a lot of markup and you know that a significant portion of it is deprecated but you are not confident in your HTML5 skills yet, you can go to the WC3 Markup Validation Service and either enter the URL to your markup page or upload/enter your markup directly and it will give you a full analysis of the validity errors in your markup and correct it for you. All you need to do is copy/paste the corrected markup back into your original file.

It would also be good to get into the practice of cutting your CSS out of the markup file and pasting it into a .css file that you would in turn reference from your markup file.