HTML Text Formatting

HTML can define many elements for formatted output, such as bold and italic text.

There are many examples below, you can try them yourself:

HTML text formatting examples

Text formatting
This example demonstrates how to format text in an HTML file.
Preformatted text
This example demonstrates how to control blank lines and spaces using the pre tag.
Label for 'Computer Output'
This example demonstrates the display effects of different 'computer output' tags.
Address
This example demonstrates how to write addresses in HTML files.
Abbreviations and initials
This example demonstrates how to implement abbreviations or initials.
Text direction
This example demonstrates how to change the direction of text.
Block quote
This example demonstrates how to implement quotes of different lengths.
Delete character effect and insert character effect
This example demonstrates how to mark deleted text and insert text.

How to view HTML source code

Have you ever had such an experience, when you see a fantastic site, you are very curious about how the developers implemented it?

Have you ever seen some web pages and wondered how they were made?

To reveal a website's technical secrets, it's actually very simple. Click the 'View' menu in the browser and select 'View Source File'. Then you will see a pop-up window, which contains the actual HTML code.

Text Formatting Tags

Tag Description
<b> Define bold text.
<big> Define large text.
<em> Define emphasized text.
<i> Define italic text.
<small> Define small text.
<strong> Define emphasis.
<sub> Define subscript text.
<sup> Define superscript text.
<ins> Define inserted text.
<del> Define deleted text.
<s> Not recommended for use.Use <del> instead.
<strike> Not recommended for use.Use <del> instead.
<u> Not recommended for use.Use style (style) instead.

Label for 'Computer Output'

Tag Description
<code> Define computer code.
<kbd> Define a keyboard code.
<samp> Define a computer code sample.
<tt> Define typewriter code.
<var> Define a variable.
<pre> Define preformatted text.
<listing> Not recommended for use.Use <pre> instead.
<plaintext> Not recommended for use.Use <pre> instead.
<xmp> Not recommended for use.Use <pre> instead.

Citations, references, and term definitions

Tag Description
<abbr> Define an abbreviation.
<acronym> Define an acronym.
<address> Define an address.
<bdo> Define text direction.
<blockquote> Define a long quotation.
<q> Define a short quotation.
<cite> Define a citation, reference.
<dfn> Define a definition item.

Extended Reading:

Changing Text Appearance and Meaning