Skip to content

Instantly share code, notes, and snippets.

@jethusang
Created May 16, 2025 20:18
Show Gist options
  • Select an option

  • Save jethusang/1dfb802d3b0a92394bd868209f1f47c8 to your computer and use it in GitHub Desktop.

Select an option

Save jethusang/1dfb802d3b0a92394bd868209f1f47c8 to your computer and use it in GitHub Desktop.
Text Formatting in HTML

Text Formatting in HTML

HTML provides several elements for defining text with special meaning. Here are some common ones:


Bold and Italic Text

  • Bold: Use the <b> or <strong> tag.
  • Italic: Use the <i> or <em> tag.

Subscript and Superscript Text

  • Subscript: Use the <sub> tag.
  • Superscript: Use the <sup> tag.

Other Formatting Tags

  • Small Text: Use the <small> tag.
  • Marked Text: Use the <mark> tag.
  • Deleted Text: Use the <del> tag.
  • Inserted Text: Use the <ins> tag.
  • Underlined Text: Use the <u> tag.
  • Strikethrough Text: Use the <s> tag.
  • Keyboard Input: Use the <kbd> tag.
  • Code Snippet: Use the <code> tag.
  • Sample Output: Use the <samp> tag.
  • Variable: Use the <var> tag.
  • Preformatted Text: Use the <pre> tag.
  • Abbreviations: Use the <abbr> tag.
  • Citations: Use the <cite> tag.
  • Quotations:
    • Inline Quote: Use the <q> tag.
    • Block Quote: Use the <blockquote> tag.
  • Time Element: Use the <time> tag to represent a specific date/time.

Tips

  • Naming Files: Always ensure your HTML files have the .html extension.
  • Live Server: Use Live Server to see changes in real-time without needing to refresh the browser manually.
  • Semantic Tags: Prefer semantic tags like <strong> and <em> over <b> and <i> for better accessibility.

Conclusion

By using HTML formatting tags, you can add meaning and emphasis to your text content. Mastering these tags helps improve the structure and accessibility of your web pages.

Happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment