Wednesday, 30 October 2013

Basic Text Formatting in HTML

Basic Text Formatting in HTML

While formatting our documents we often need to format some pieces of text as bold, italic, underline, superscript, subscript and/or strikethrough to show the importance of the text. HTML provides us different tags perform such type of formatting. Let’s have look at each one!

Bold or Strong:

In HTML to format some piece of text as bold we can use and/or elements.

Example:
Code:
<b>I’m bold text</b>
<b>I’m strong text</b>

                
Result:
I’m bold text
I’m strong text

Difference between Bold & Strong:

There are some browsers which are used by the special peoples (disabled) who can see nothing on the screen. Rending of webpages on such browsers is done by reading text loudly. The text wrapped in strong element is read stressfully which indicates that the stressed text is important, while the text wrapped in b element is read normally without producing any stress to inform the listener that there is nothing special here

Italic:

In HTML to format some piece of text as italic we can use elements.

Example:
Code:
<i>I’m italic text</i>
                
Result:
I’m italic text

Underline

In HTML to format some piece of text as underlined we can use elements.

Example:
Code:
<u>I’m underlined text</u>
                
Result:
I’m underlined text

Super/Sub Scripts

In HTML to format some piece of text as underlined we can use elements.

Example:
Code:
He's the 11<sup>th</sup> player of the team.
a<sub>1n</sub>, a<sub>2n</sub>, a<sub>3n</sub>......,a<sub>n</sub>
Result:
He's the 11th player of the team.
a1n, a2n, a3n......,an

Strike Through:

In HTML to format some piece of text as strike through we can use elements.

Example:
Code:
<Strike>I’m strike through text</strike>
Result:
I’m strike through text

Linefeed

Goto Line Break Section in the …………………… Post

Paragraph

In HTML to divide a long topic, under discussion, into different paragraph we use <p> element.

Example:
Code:
<p>I’m a paragraph.</p>
<p>I’m another paragraph.</p>
Result:

I’m a paragraph.

I’m another paragraph.


Note: The ending tag of the paragraph </p> is optional, you can get the accurate result without using it. But if you are using XHTML thne it would be necessary to include the ending tag of Paragraph Element.

The Paragraph Element automatically includes a Line Break Element, so you don't need to include line break to feed a new line after a paragraph.

No comments :

Post a Comment