Write an HTML program for text formatting (bold, italic, subscript, superscript)

Description: Create a web page that shows important text, emphasised text, highlighted text, the formula of water (H2O) and the square of a number (5 squared).

Hint:

  • Use strong, em, mark, sub and sup tags.

HTML program for text formatting

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Text Formatting</title>
</head>
<body>
  <p>This is <strong>important</strong> text.</p>
  <p>This is <em>emphasised</em> text.</p>
  <p>This is <mark>highlighted</mark> text.</p>
  <p>The formula of water is H<sub>2</sub>O.</p>
  <p>5<sup>2</sup> is 25.</p>
  <p>Old price <del>$100</del>, new price <ins>$80</ins>.</p>
</body>
</html>

Output in the browser:

Output in the browser

This is important text.

This is emphasised text.

This is highlighted text.

The formula of water is H2O.

52 is 25.

Old price $100, new price $80.

How it works

  • strong shows bold and em shows italic text.
  • sub lowers the text and sup raises it.
  • del draws a line through the text and ins underlines it.

Read HTML Formatting.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.