HTML Text Formatting Techniques

HTML Text Formatting Techniques: We have already learnt about style element using which we may alter or change the look of our content within an HTML document but there are a few HTML formatting options like bold, italic, underlined, computer code, highlighted etc. Let us look at the examples of each one of these.

Bold Formatting of Text in HTML with <strong>:

Though HTML does have a straight forward <b></b> for marking a text bold but as of W3C’s recommendations, we must not use it for merely presentational reasons. The best way to mark a text bold is: <strong>text</strong>. The example below depicts what <strong> does to the text:

Example 1: HTML Code Showing Text Formatting:

 <p> My First Paragraph </p>

<p>My Second Paragraph </p>

<p><strong> My Third Paragraph<strong></p>

Result:

HTML Text Formatting Bold

Example 2: Marking Text Bold:

Let’s make only the word “Third” bold in the last line or paragraph:

HTML Code:

<p>My <strong>Third</strong> Paragraph</p>

HTML Output:

HTML Formatting

HTML Formatting

Italic Text in HTML:

So far we are so used to the <i></i> tag to italicize a text that HTML coding has carried this tradition on. But W3C has recommendations not to use <i> tag for merely tilting or italicizing certain text. It suggests us to use <em> tag for this purpose. So we can use <em> text</em> for this purpose. An example below illustrates how to achieve this:

HTML Code for Italicized text:

<p>I have been moving to the strange iconic platoons there where they say <em>life loses all its wealth</em> but I have not been successful so far.</p>

Output:

HTML Formatting Emphasize Text