Overview
HTML has a large number of elements dedicated to formatting text. With the increased popularity of CSS, many of these elements have become deprecated.
The following example shows some of the basic text formatting elements:
normal Text
<b>bold text</b>
<big>big text</big>
<em>emphasized text</em>
<i>italic text</i>
<small>small text</small>
<strong>strong text</strong>
<sub>subscript text</sub>
<sup>superscript text</sup>
<ins>inserted text</ins>
<del>deleted text</del>
<code>code text</code>
<kbd>keyboard text</kbd>
<samp>sample text</samp>
<tt>teletype text</tt>
<var>variable text</var>
<pre>preformated text</pre>
This produces the following result:
bold text
big text
emphasized text
italic text
small text
strong text
subscript text
superscript text
inserted text
code text
keyboard text
sample text
teletype text
variable text
preformated text
Text Formatting Tags
The following table lists the general text formatting tags:
Tag | Description |
---|---|
<b> | Defines bold text |
<big> | Defines big text |
<em> | Defines emphasized text |
<i> | Defines italic text |
<small> | Defines small text |
<strong> | Defines strong text |
<sub> | Defines subscripted text |
<sup> | Defines superscripted text |
<ins> | Defines inserted text |
<del> | Defines deleted text |
The following table lists the text formatting tags that render the text in a "computer output" style:
Tag | Description |
---|---|
<code> | Defines computer code text |
<kbd> | Defines keyboard text |
<samp> | Defines sample computer code |
<tt> | Defines teletype text |
<var> | Defines a variable |
<pre> | Defines preformatted text |
The following table lists the text formatting tags that are considered citations, quotations, and definitions:
Tag | Description |
---|---|
<abbr> | Defines an abbreviation |
<acronym> | Defines an acronym |
<address> | Defines contact information for the author/owner of a document |
<bdo> | Defines the text direction |
<blockquote> | Defines a long quotation |
<q> | Defines a short quotation |
<cite> | Defines a citation |
<dfn> | Defines a definition term |
Tag Description
The b tag is a font-style tag used to set the font weight to bold.
This tag has the form:
<b>text</b>
HTML5 and HTML4.01 Differences
None.
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
Normal Text
<b>Bold text</b>
<i>Italic text</i>
<big>Big text</big>
<small>Small text</small>
<tt>Teletype text</tt>
This produces the following result:
Bold text
Italic text
Big text
Small text
Teletype text
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML 2 |
---|---|
Empty Tag: | No |
Tag Description
The em tag is used to emphasize text content. All current browsers render em
content in italics.
This tag has the form:
<em>text</em>
HTML5 and HTML4.01 Differences
None.
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
<em>Emphasized Text</em>
This produces the following result:
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML 2 |
---|---|
Empty Tag: | No |
Tag Description
The i tag is a font-style tag used to set the font style to italic.
This tag has the form:
<i>text</i>
HTML5 and HTML4.01 Differences
None.
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
Normal Text
<b>Bold text</b>
<i>Italic text</i>
<big>Big text</big>
<small>Small text</small>
<tt>Teletype text</tt>
This produces the following result:
Bold text
Italic text
Big text
Small text
Teletype text
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML 2 |
---|---|
Empty Tag: | No |
UNSUPPORTED
in HTML5
DEPRECATED
in HTML4.01
Tag Description
The strike tag is used to define strikethrough text.
This tag has the form:
<strike>text</strike>
HTML5 and HTML4.01 Differences
Not supported in HTML5. Use the <del>
or <s>
tag instead.
Global Attributes
Attribute | Value | Description |
---|---|---|
class | classname | Sets the classname of the element |
dir | rtl ltr |
Sets the text direction for the content of the element |
id | id | Sets a unique id for the element |
lang | lang_code | Sets the language code for the content of the element |
style | style_def | Sets the inline style of the element |
title | text | Sets extra information about the element |
Event Attributes
Attribute | Value | Description |
---|---|---|
onclick | script | Executes script on a mouse click |
ondblclick | script | Executes script on a mouse double-click |
onkeydown | script | Executes script when a key is pressed |
onkeypress | script | Executes script when a key is pressed and released |
onkeyup | script | Executes script when a key is released |
onmousedown | script | Executes script when a mouse button is pressed |
onmousemove | script | Executes script when the mouse cursor moves |
onmouseout | script | Executes script when the mouse cursor moves out of the element |
onmouseover | script | Executes script when the mouse cursor moves over the element |
onmouseup | script | Executes script when a mouse button is released |
Examples
The following example shows the basic use of this tag:
<strike>
Strikethrough text
</strike>
This produces the following result:
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML 3 |
---|---|
Empty Tag: | No |
Tag Description
The
<strong>
tag is used to define important text content. The text is typically rendered using a bold, non-italicized font.
This tag has the form:
<strong>text</strong>
HTML5 and HTML4.01 Differences
In HTML4.01, the <strong>
tag defined strong emphasized text, but in HTML5 it defines important text.
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
<strong>Strong Text</strong>
This produces the following result:
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML 2 |
---|---|
Empty Tag: | No |
Tag Description
The ins tag is used to identify text that has been inserted into a document.
This tag has the form:
<ins cite="URL" datetime="datetime">
</ins>
HTML5 and HTML4.01 Differences
None.
Attributes
Attribute | Value | Description |
---|---|---|
cite | URL | Specifies a URL to a document which explains why the text was deleted |
datetime | YYYY-MM-DD Thh:mm:ssTZD |
Specifies the date and time when the text was deleted |
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
<p>The sky is:
<del>red</del>
<ins>blue</ins>
</p>
This produces the following result:
The sky is:
red
blue
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML4 |
---|---|
Empty Tag: | No |
Tag Description
The code tag is used to identify text as computer code. Most browsers render
code
content in a fixed-width font, such as Courier.
This tag has the form:
<code>text</code>
HTML5 and HTML4.01 Differences
None.
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
<code>Code Text</code>
This produces the following result:
Code Text
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML 2 |
---|---|
Empty Tag: | No |
Tag Description
The del tag is used to identify text that has been deleted from a document.
This tag has the form:
<del cite="URL" datetime="datetime">
</del>
HTML5 and HTML4.01 Differences
None.
Attributes
Attribute | Value | Description |
---|---|---|
cite | URL | Specifies a URL to a document which explains why the text was deleted |
datetime | YYYY-MM-DD Thh:mm:ssTZD |
Specifies the date and time when the text was deleted |
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
<p>The sky is:
<del>red</del>
<ins>blue</ins>
</p>
This produces the following result:
The sky is:
red
blue
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML4 |
---|---|
Empty Tag: | No |
Tag Description
The kbd tag is used to identify keystrokes that the user needs to make on the keyboard. Most browsers render
kbd
content using a monospace font.
This tag has the form:
<kbd>
text
</kbd>
HTML5 and HTML4.01 Differences
None.
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
<kbd>Keyboard Text</kbd>
This produces the following result:
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML 2 |
---|---|
Empty Tag: | No |
Tag Description
The pre tag is used to define preformatted text. The preformatted text is typically rendered using a fixed-width font (usually Courier). In addition, both spaces and line breaks are preserved.
This tag has the form:
<pre>text</pre>
HTML5 and HTML4.01 Differences
None.
Attributes
Attribute | Value | Description |
---|---|---|
width | number | Specifies the maximum number of characters per line
HTML4:
![]()
HTML5:
![]() |
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
<pre>
Text in a pre element
is displayed in a fixed-width
font, and it preserves
both spaces and
line breaks
</pre>
This produces the following result:
Text in a pre element is displayed in a fixed-width font, and it preserves both spaces and line breaks
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML 2 |
---|---|
Empty Tag: | No |
Tag Description
The <small>
tag is a font-style tag used to decrease the font size by one increment.
This tag has the form:
<small>text</small>
HTML5 and HTML4.01 Differences
None.
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
Normal Text
<b>Bold text</b>
<i>Italic text</i>
<big>Big text</big>
<small>Small text</small>
<tt>Teletype text</tt>
This produces the following result:
Bold text
Italic text
Big text
Small text
Teletype text
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML 2 |
---|---|
Empty Tag: | No |
Tag Description
The <sub>
tag is used to define subscript text. Subscript text appears half a character below the baseline.
This tag has the form:
<sub>text</sub>
HTML5 and HTML4.01 Differences
None.
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
<p>Water = H<sub>2</sub>O</p>
This produces the following result:
Water = H2O
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML 2 |
---|---|
Empty Tag: | No |
Tag Description
The <sup>
tag is used to define superscript text. Superscript text appears half a character above the baseline.
This tag has the form:
<sup>text</sup>
HTML5 and HTML4.01 Differences
None.
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
<p>E = MC<sup>2</sup></p>
This produces the following result:
E = MC2
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML 2 |
---|---|
Empty Tag: | No |
UNSUPPORTED
in HTML5
Tag Description
The tt tag is a font-style tag used to render the text using a teletype font (usually a monospace font).
This tag has the form:
<tt>text</tt>
HTML5 and HTML4.01 Differences
Not supported in HTML5.
Global Attributes
Attribute | Value | Description |
---|---|---|
class | classname | Sets the classname of the element |
dir | rtl ltr |
Sets the text direction for the content of the element |
id | id | Sets a unique id for the element |
lang | lang_code | Sets the language code for the content of the element |
style | style_def | Sets the inline style of the element |
title | text | Sets extra information about the element |
xml:lang | lang_code | Sets the language code for the content of the element in XHTML documents |
Event Attributes
Attribute | Value | Description |
---|---|---|
onchange | script | Executes script when an element's value changes |
onclick | script | Executes script on a mouse click |
ondblclick | script | Executes script on a mouse double-click |
onfocus | script | Executes script when an element gets focus |
onkeydown | script | Executes script when a key is pressed |
onkeypress | script | Executes script when a key is pressed and released |
onkeyup | script | Executes script when a key is released |
onmousedown | script | Executes script when a mouse button is pressed |
onmousemove | script | Executes script when the mouse cursor moves |
onmouseout | script | Executes script when the mouse cursor moves out of the element |
onmouseover | script | Executes script when the mouse cursor moves over the element |
onmouseup | script | Executes script when a mouse button is released |
Examples
The following example shows the basic use of this tag:
Normal Text
<b>Bold text</b>
<i>Italic text</i>
<big>Big text</big>
<small>Small text</small>
<tt>Teletype text</tt>
This produces the following result:
Bold text
Italic text
Big text
Small text
Teletype text
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
![]() |
Miscellaneous Information
Defined In: | HTML 2 |
---|---|
Empty Tag: | No |
Tag Description
The var tag is used to indicate that the text is a variable and shouldn’t be taken literally.
This tag has the form:
<var>text</var>
HTML5 and HTML4.01 Differences
None.
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
<var>Variable Text</var>
This produces the following result:
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML 2 |
---|---|
Empty Tag: | No |