HTML text formatting

In HTML, there are tags for changing the appearance of the text, such as <b> and <i>. They are used to select text in bold or italic, such tags in HTML are called tags for formatting.

Text formatting

This example demonstrates how you can edit text in an HTML document using special tags:

<p>This is the <sub>subscript</sub> and the <sup>superscript</sup></p>
Try it »

Tag <pre>

The <pre> tag allows you to select a part of the source text that should be displayed by the browser in its original form, that is, the same characters and with the same number of spaces and line breaks. All text between the opening <pre> tag and the closing </pre> tag will be displayed in monospaced font:

It saves the author's text formatting
(leaves unchanged)
and makes the font monospaced
Try it »

Tags for code

The example shown below demonstrates the difference in output of the contents of the tags to the screen:

<p><code>Source code</code>
  <kbd>Keyboard input</kbd>
  <samp>Sample code</samp>
  <var>Selecting a variable</var>
<p>These tags are usually used to show the program code on the page.</p>
Try it »

Tag <address>

The address is a common element of many HTML documents, to allocate an address on the page, there is a special <address> tag separating the text enclosed in it from all other content.

Most often it is used to highlight contact information, for example, an e-mail address or a method of communication with the author/owner of the document, article or site:

<p>You can find me on my website</p>
  <a href="">My website for communication</a>
Try it »


The example shows how you can write an abbreviation:

<p><abbr title="Unknown flying object">UFO</abbr><br><br><br>
  The title attribute is needed for the tooltip, it appears
  when you move the cursor over the abbreviation.
Try it »

Text direction

The example shows how you can change the direction of the text:

  The bdo tag specifies the direction of the text - from left to right and vice versa.<br><br>
  <bdo dir="rtl">
    This is our text
Try it »


In HTML, there are two tags for highlighting quotes in the text - <q> and <blockquote>. The <q> tag is a inline element and is intended to highlight short citations directly in the paragraph text. Text placed inside the <q> element is displayed by default in double quotes by most browsers.

Unlike the <q> tag, the <blockquote> tag is a block element, it is intended to highlight long quotes that are more similar in volume to whole paragraphs. In most browsers, the text of the <blockquote> element will be displayed with a small indent to the right and have line breaks before and after itself:

<p>A long quote:</p>
  This is a very long quote.This is a very long quote.This is a very long quote.
  This is a very long quote.This is a very long quote.This is a very long quote.
<p><b>For long quotes, the browser inserts indents from all sides.</b>
  Short quote: 
  <q>This is a short quote.</q><br>
  <b>Short quotes are enclosed in double quotes.</b>
Try it »

Removed and inserted text

The example demonstrates how you can mark text in a document that has been deleted (marked as a crossed outline) or inserted (marked as underlined):

  The contents of the del tag, most browsers display <del>strikethrough</del>, and
  the content of the ins tag - <ins>underlined</ins>
Try it »

Note: you can also specify a strikethrough and an underscore using the CSS property of text-decoration.

Copying materials from this site is possible only with the permission of the site administration and
when you specify a direct active link to the source.
2011 - 2021 © | ruen