|
Beginner Tip:
Replace Your Deprecated Tags
by Larisa Thomason,
Senior Web Analyst,
NetMechanic, Inc.
Spoken languages are living things: words and phrases become popular then fall out of favor. HTML is also evolving. Some HTML tags and attributes are also becoming as obsolete as the mild English oath "Gadzooks!" Imagine how your page might look if browsers start ignoring some common - but deprecated - elements and attributes like font tags, align attributes, center tags, and other common page components.
HTML History Lesson
Why is this happening? Let's learn a little HTML history.
In the beginning, HTML was a structural language used mostly by scientists and researchers. They didn't need flashy graphics, different fonts, or even much color on a page. Pages weren't fancy and neither were the browsers that displayed them.
As browsers added new features to attract users, artists and designers became interested in creating pages that were complex and visually interesting. The overall effect of the page was just as important as its content.
For a while, HTML tried to accommodate both extremes, but it didn't work very well. Web pages were full of extra font tags, nested layout tables, and other tricks to make HTML behave like a layout language. The resulting pages contained bloated code, were harder to code and maintain, and often caused browser display problems.
Attack Of The Style Sheets
The World Wide Web Consortium (W3C) the governing body that sets HTML, XML, CSS, and other technical standards decided enough was enough with the formatting tags and deprecated them. That means those tags and attributes are marked for deletion in future versions of HTML and XHTML.
The W3C hopes to eventually replace formatting tags with Cascading Style Sheet (CSS) definitions. This 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.
But this will never be entirely successful as long as some designers continue to use HTML formatting tags instead of CSS. That's why the tags are marked for deletion in the future.
Here's a brief list of the most popular deprecated HTML tags and attributes, along with the style properties that replace them.
Deprecated Tags:
| HTML Tag
| Style Property
|
| center |
text-align:center |
| b |
font-weight:bold |
| u |
font-style:italic |
| font |
font-family:font name |
| HTML Attribute
| Style Property
|
| align |
text-align |
| background |
background-image:url(image) |
| bgcolor |
background-color |
| hspace |
padding |
| vspace |
padding |
| size |
font-size: |
Note that this is a list of the most commonly-used tags and attributes. Visit the W3C Web site for a complete list of deprecated HTML elements.
Good Coding Equals Good Communication
So, what's the big deal? Does anyone really expect browsers to stop supporting FONT tags when they're used on millions of Web pages? Probably not, but it's just good coding practice to communicate with browsers in the language they understand the best.
Imagine the confusion and hilarity if a political candidate gave a stump speech using Shakespearean English! Sure, most English-speakers would probably understand most of what he says, but effective communication means that you should understand ALL of what's being said.
When you replace your deprecated HTML tags and attributes with CSS definitions, you know that you're creating pages that future browsers will understand and interpret correctly. But that's not the only benefit.
Style sheets help you in many other ways too.
- Shorter download times: With CSS, you can remove many of your layout tables, redundant formatting tags and attributes. The smaller pages download more quickly. Check your page's download time using HTML Toolbox's Load Time Check feature. You'll know for sure if you need to put your pages on a diet.
- Less time to code: Again, you're writing less code overall so you can focus on writing good content for your page. That helps you with both human visitors and search engine spiders.
If you're not sure what makes good content, we recommend "The Copywriter's Handbook" by Robert Bly. It's an excellent resource for all writers.
- Easier to maintain: A single change to a CSS definition can change an entire Web page or even an entire Web site if you're using external style sheets. That greatly reduces the chance of coding errors that result from improperly nested formatting tags.
HTML toolbox easily catches nesting errors, but isn't it better not to make them in the first place? It takes time and effort to identify and correct them.
|
Even with these advantages, many webmasters are reluctant to make the switch - mainly because they don't feel comfortable working with style sheets. So, in an upcoming CSS Tip, we'll take a sample Web page designed with font and other deprecated tags and upgrade it to CSS. You'll see just how simple it is to create slimmer, more reliable pages.
In the meantime, visit these online resources to learn more about deprecated HTML tags and CSS:
|