Home / Articles / Programming languages / Markup languages / HTML & CSS / Formatting text in HTML

Formatting text in HTML

Formatting text in HTML
 
Formatting text in HTML
  • Currently 0 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 0/5 (0 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.


Text formatting - different means to edit text, as for example - choosing font style and usage of effects that allow you to change the text. Table 1 shows the basic tags that are used to customize the text.

Table 1. Their order in this case is not important.

HTML code

Description

Example

<b>Text</b>

Bold text

Text

<i>Text</i>

Italic text 

Text

<sup>Text</sup>

Superscript

e=mc²

<sub>Text</sub>

Subscript

H2O

<pre>Text</pre>

The text is written as it is, including all spaces

Text

<em>Text</em>

Italic text 

Text

<strong>Text</strong>

Bold text

Text

Any text formatting tags can be used together. To make the text bold and italic, use combination of tags b and i (example 1). Their order in this case is not important.

Example 1. Bold italic text.

<b><i>"And where are my cookies?!"</i></b> - A naughty boy cried.
Formatting text, example 1

Using tags sup and sub shifts the text relative to the baseline and reduces the size of the font. If you need to make the size even smaller, you can add the tag small (example 2).

Example 2. Creating subscript.

<b>Sulfuric acid formula:</b> <i>H<sub><small>2</small></sub>SO<sub><small>4</small></sub></i>
Formatting text, example 2

Tags strong and em perform the same functions as tags b and i, but they are less long, more familiar and easy-to-use.

It should be noted that the tags b and strong, i and em are not exactly equivalent and interchangeable. Tag b - is a tag of physical markup and sets bold text, whereas the tag strong - is a tag of logical markup and indicates the importance of the marked text. Such a division of tags on logical and physical was originally designed to make the HTML language universal, including for the language to be independent of the output device. Theoretically, if we use, for example, voice browser, a text, changed by tags b and strong, will be shown in differently. However, as it turns out that in popular browsers the result of using these tags is equivalent.


 

Read also

Font size in HTML

Font size in HTML

Text alignment in HTML

Text alignment in HTML

CSS: working with text

CSS: working with text

Details about "float" property

Details about "float" property

Post comment

basicuse.net
html5_css
106160485398655174790

Quick navigation

General navigation