Deprecated tags are old HTML tags that browsers no longer support well. Avoiding them helps your website work better and look good on all devices.
Avoiding deprecated tags in HTML
<strong>Old (deprecated) tag:</strong> <center>Centered text</center> <strong>New (recommended) way:</strong> <p style="text-align: center;">Centered text</p>
Use CSS for styling instead of old tags like <center> or <font>.
Modern HTML uses semantic tags and CSS for layout and appearance.
<strong> instead of <b> because it means important text, not just bold style.<b>Bold text</b> <strong>Bold text</strong>
<em> for emphasized text instead of <i> which is just for style.<i>Italic text</i> <em>Italic text</em>
<font> tag to change colors.<font color="red">Red text</font> <span style="color: red;">Red text</span>
text-align property instead of the <center> tag.<center>Centered text</center> <p style="text-align: center;">Centered text</p>
This example shows how to center and style text using CSS instead of deprecated tags like <center> or <font>. It uses semantic tags like <header>, <main>, and <footer> for better structure and accessibility.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Avoid Deprecated Tags</title> <style> .centered { text-align: center; color: darkblue; font-weight: bold; font-style: italic; } </style> </head> <body> <header> <h1 class="centered">Welcome to My Website</h1> </header> <main> <p>This paragraph uses modern HTML and CSS.</p> <p class="centered">This text is centered and styled without deprecated tags.</p> </main> <footer> <p>Ā© 2024 My Website</p> </footer> </body> </html>
Deprecated tags may still work in some browsers but can cause problems in the future.
Using CSS keeps your HTML clean and separates content from design.
Semantic HTML helps screen readers and improves SEO.
Avoid old tags like <center>, <font>, <b>, and <i>.
Use CSS for styling and layout instead.
Use semantic HTML tags for better structure and accessibility.
Practice
Solution
Step 1: Understand deprecated tags
The<center>tag was used to center content but is now deprecated in favor of CSS styling.Step 2: Identify semantic tags
<section>,<article>, and<nav>are semantic HTML5 tags and are not deprecated.Final Answer:
<center> -> Option BQuick Check:
Deprecated tag = <center> [OK]
- Confusing semantic tags with deprecated tags
- Thinking all tags with angle brackets are deprecated
- Assuming
<b>is semantic
<b> tag?Solution
Step 1: Identify semantic bold tag
The<strong>tag is the semantic way to indicate important or bold text.Step 2: Recognize deprecated and incorrect tags
<b>is deprecated for styling;<bold>is invalid;<em>and<i>are for emphasis and italic style, not bold.Final Answer:
<strong>Text</strong> -> Option DQuick Check:
Use <strong> for bold text [OK]
- Using <b> for styling instead of <strong>
- Confusing <em> with bold
- Using invalid tags like <bold>
<center><h1>Welcome</h1></center>
Solution
Step 1: Recognize deprecated tag behavior
Although the<center>tag is deprecated in HTML5, modern browsers continue to support it for backward compatibility and will center the content.Step 2: Default heading alignment
The<h1>inside<center>will be rendered centered horizontally.Final Answer:
The heading 'Welcome' centered horizontally -> Option AQuick Check:
Deprecated <center> still centers [OK]
- Thinking deprecated tags are completely ignored
- Believing deprecated tags cause syntax errors
- Confusing <center> with italic or bold
<font color='red'>Warning!</font>
Solution
Step 1: Recognize deprecated tag usage
The<font>tag is deprecated and should not be used for styling.Step 2: Use semantic tag with CSS
Use a<span>tag and apply color with CSS, e.g.,style="color:red;".Final Answer:
Replace <font> with <span> and use CSS color -> Option AQuick Check:
Use CSS for styling, not <font> [OK]
- Trying to fix <font> with invalid attributes
- Using <b> for color styling
- Ignoring CSS for styling
Solution
Step 1: Avoid deprecated tags
<center>and<font>are deprecated and should not be used.Step 2: Use CSS for styling
Applytext-align:center;andfont-style:italic;using thestyleattribute or external CSS on a semantic tag like<p>.Final Answer:
<p style='text-align:center; font-style:italic;'>Text</p> -> Option CQuick Check:
Use CSS styles, not deprecated tags [OK]
- Using <center> or <font> for layout and style
- Mixing bold and italic tags incorrectly
- Not applying CSS for alignment or style
Ready to prove it?
Pass the test and this pattern moves unknown
