Learn how to use the <strike> and <center> tags, along with their modern CSS alternatives.
To write an HTML program that demonstrates the use of <strike> (strike out) and <center> tags, along with their modern CSS alternatives.
HTML provides two useful tags for text presentation:
<strike> — displays text with a <center> — aligns text or content <strike> and <center> tags are deprecated in HTML5. You should use CSS instead:
text-decoration: line-through; for strike throughtext-align: center; for centering content| Purpose | Old Tag | Modern CSS Alternative | Status |
|---|---|---|---|
| Strike through text | <strike> |
text-decoration: line-through; |
Deprecated |
| Strike through (semantic) | <del> |
text-decoration: line-through; |
Valid |
| Center alignment | <center> |
text-align: center; |
Deprecated |
| Center block | <center> |
display: block; margin: 0 auto; |
Deprecated |
| Scenario | Recommended Method | Reason |
|---|---|---|
| Showing deleted/removed content | <del> |
Semantic meaning for deleted content |
| Showing old price crossed out | text-decoration: line-through; |
Visual only, no semantic meaning needed |
| Centering a heading | text-align: center; |
Clean, modern, works everywhere |
| Centering a block element | margin: 0 auto; with display: block; |
Proper block-level centering |
| Legacy code compatibility | <strike> or <center> |
Still works in browsers, but not recommended |
| Mistake | Why It's Wrong | Correct Way |
|---|---|---|
Using <strike> for deleted content |
No semantic meaning | Use <del> for deleted content |
Using <center> for all centering |
Deprecated; limited control | Use text-align: center; or margin: 0 auto; |
| Forgetting to close tags | Invalid HTML | Always close: <strike>...</strike> |
Using text-align: center; on block elements |
Only works on inline content inside the block | Use margin: 0 auto; for block centering |
<strike> and <center> are deprecated in HTML5.<del> is the semantic alternative for deleted content.text-decoration: line-through; creates the strike effect.text-align: center; centers inline content, while margin: 0 auto; centers block elements.You have successfully:
<strike> and <center> tags.<del>).<strike> and <center> still work, they are deprecated. Always use CSS for new projects. Use <del> when you need semantic meaning for deleted content!
overline and underline!
ایک HTML پروگرام لکھنا جو <strike> (اسٹرائیک آؤٹ) اور <center> (سینٹر) ٹیگز کے استعمال کو ظاہر کرتا ہے، ان کے جدید CSS متبادل کے ساتھ۔
HTML ٹیکسٹ پریزنٹیشن کے لیے دو مفید ٹیگز فراہم کرتا ہے:
<strike> — ٹیکسٹ کو <center> — ٹیکسٹ یا مواد کو صفحہ کے <strike> اور <center> دونوں ٹیگز HTML5 میں متروک (deprecated) ہیں۔ آپ کو اس کی بجائے CSS استعمال کرنا چاہیے:
text-decoration: line-through;text-align: center;| مقصد | پرانے ٹیگ | جدید CSS متبادل | حیثیت |
|---|---|---|---|
| ٹیکسٹ کو کٹی ہوئی لکیر | <strike> |
text-decoration: line-through; |
متروک |
| کٹی ہوئی لکیر (سیمینٹک) | <del> |
text-decoration: line-through; |
درست |
| سینٹر کی ترتیب | <center> |
text-align: center; |
متروک |
| بلاک کو سینٹر کرنا | <center> |
display: block; margin: 0 auto; |
متروک |
| صورت حال | تجویز کردہ طریقہ | وجہ |
|---|---|---|
| حذف شدہ مواد دکھانا | <del> |
حذف شدہ مواد کے لیے سیمینٹک معنی |
| پرانے قیمت کو کاٹ کر دکھانا | text-decoration: line-through; |
صرف بصری، سیمینٹک معنی کی ضرورت نہیں |
| ہیڈنگ کو سینٹر کرنا | text-align: center; |
صاف، جدید، ہر جگہ کام کرتا ہے |
| بلاک عنصر کو سینٹر کرنا | margin: 0 auto; کے ساتھ display: block; |
بلاک‑لیول سینٹرنگ کے لیے صحیح |
| پرانی کوڈ کی مطابقت | <strike> یا <center> |
براؤزرز میں اب بھی کام کرتا ہے، لیکن تجویز نہیں |
| غلطی | یہ کیوں غلط ہے | صحیح طریقہ |
|---|---|---|
حذف شدہ مواد کے لیے <strike> کا استعمال |
سیمینٹک معنی نہیں | حذف شدہ مواد کے لیے <del> استعمال کریں |
تمام سینٹرنگ کے لیے <center> کا استعمال |
متروک؛ محدود کنٹرول | text-align: center; یا margin: 0 auto; استعمال کریں |
| ٹیگز بند کرنا بھول جانا | غلط HTML | ہمیشہ بند کریں: <strike>...</strike> |
بلاک عناصر پر text-align: center; کا استعمال |
صرف بلاک کے اندر ان لائن مواد پر کام کرتا ہے | بلاک سینٹرنگ کے لیے margin: 0 auto; استعمال کریں |
<strike> اور <center> HTML5 میں متروک ہیں۔<del> حذف شدہ مواد کے لیے سیمینٹک متبادل ہے۔text-decoration: line-through; اسٹرائیک اثر پیدا کرتا ہے۔text-align: center; ان لائن مواد کو سینٹر کرتا ہے، جبکہ margin: 0 auto; بلاک عناصر کو سینٹر کرتا ہے۔آپ نے کامیابی سے:
<strike> اور <center> ٹیگز کا استعمال کیا۔<del>) کے بارے میں سیکھا۔<strike> اور <center> اب بھی کام کرتے ہیں، وہ متروک ہیں۔ نئے پروجیکٹس کے لیے ہمیشہ CSS استعمال کریں۔ حذف شدہ مواد کے لیے سیمینٹک معنی کی ضرورت ہونے پر <del> استعمال کریں!
overline اور underline کے ساتھ تجربہ کریں!