Text formatting

Text formatting is a means of changing it, such as selecting the font face and using effects that allow you to change the appearance of the text. In Table. 1 lists the main tags that are used to change the design of the text.

Table. 1. Tags for text formatting
HTML Code Description Example
<B> Text </ b> Bold text Text
<I> Text </ i> Italic text Text
<Sup> Text </ sup> Superscript E = mc2
<Sub> Text </ sub> Subscript H 2 O
<Pre> Text </ pre> Text is written as 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 with each other. To make the text bold and italic at the same time, a combination of <B> and <I> tags is used (example 1). Their order in this case is not important.

Example 1. Bold italic text

Valid code
<! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 // EN" "http://www.w3.org/TR/html4/strict.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text / html; charset = windows-1251">
<Title> Text </ title>
</ Head>
<Body>
<P> <b> <i> "And where is the cookie and brewing?!" </ I> </ b> - exclaimed Malchish the bad guy. </ P>
</ Body>
</ Html>

The result of this example is shown in Fig. 1.

Fig. 1

Fig. 1. Type of italic bold text

Using the <SUP> and <SUB> tags shifts the text relative to the baseline and reduces the font size. If you need to reduce the index, you can also add the <SMALL> tag (example 2).

Example 2. Creating a lower index

Valid code
<! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 // EN" "http://www.w3.org/TR/html4/strict.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text / html; charset = windows-1251">
<Title> Text </ title>
</ Head>
<Body>
<P> <b> Sulfuric acid formula: </ b> <i> H <sub> <small> 2 </ small> </ sub> SO <sub> <small> 4 </ small> </ sub> < / I> </ p>
</ Body>
</ Html>

The result of this example is shown in Fig. 2.

Fig. 2

Fig. 2. The subscript in the text

The tags <STRONG> and <EM> perform the same functions as the <B> and <I> tags , but writing them is shorter, more familiar, and more convenient.

It should be noted that <B> and <STRONG> tags , as well as <I> and <EM>, are not exactly equivalent and replaceable. The first <B> tag is a physical markup tag and sets the bold text, and the <STRONG> tag is a logical markup tag and determines the importance of the tagged text. This separation of tags into logical and physical formatting was originally intended to make HTML universal, including that independent of the output device. Theoretically, if you use, for example, a speech browser, then the text created with the tags <B> and <STRONG> will be marked differently. However, it turned out that in popular browsers the result of using these tags is equivalent.

Copyright © www.htmlbook.ru