HTML Formatting

HTML Formatting

HTML Formatting

Learn how to format text and content in HTML for better presentation and readability!

Understanding HTML Formatting

HTML provides various elements and attributes to format text and content, allowing you to enhance the visual appearance of your web pages. Proper formatting not only improves readability but also adds emphasis and clarity to your content.

Text Formatting

HTML offers several tags to format text, including:

  • <strong> or <b>: Renders text in bold.
  • <em> or <i>: Renders text in italic.
  • <u>: Renders text with an underline.
  • <del>: Renders text with a strikethrough.
  • <sub>: Renders text as subscript.
  • <sup>: Renders text as superscript.

Text Alignment

You can align text using the align attribute within block-level elements:

  • align="left": Aligns text to the left.
  • align="center": Centers text.
  • align="right": Aligns text to the right.
  • align="justify": Justifies text, making it flush with both the left and right margins.

Line Breaks and Horizontal Rules

You can use the <br> tag to insert line breaks within text, and the <hr> tag to create horizontal rules, dividing content sections.

Preformatted Text

Enclose preformatted text within the <pre> tag to preserve whitespace and line breaks, useful for displaying code snippets or preserving text formatting.


HTML comments are used to add notes or annotations within the code. They are not visible in the browser's output but provide valuable information for developers.

<!-- This is a comment -->

Practice: Experiment with different text formatting elements and attributes to style your content effectively. Consider using comments to document your code and improve its maintainability.

Practice Your CSS Skills

Enhance your web design skills with HTML and CSS. Let your creativity shine and build captivating web experiences!

© 2023 Your Website. All rights reserved.