Saturday, February 12, 2011

Simple Formatting in HTML

To start with simple formatting we have <B><I><U> (Each of which have their closing tags of-course)


As you might have guessed any text put between <B> and </B> will turn bold. <I> will make it italic and <U> to have it underlined.


So for the code below:



<HTML>
   <BODY>
      Welcome to the world of HTML.
 <B>This text is bold. </B>
 <I>This text is italic. </I>
 <U>This text is underlined. </U>
   </BODY>
</HTML>



The output should be:




Wait! There is something wrong here! Everything appears to be put on the same line.
Yes, Web browsers can not tell / interpret that you want text on separate lines until you tell it.
So tell it.



<HTML>
   <BODY>
      Welcome to the world of HTML.<BR>
  <B>This text is bold. </B><BR>
  <I>This text is italic. </I><BR>
  <U>This text is underlined. </U><BR>
   </BODY>
</HTML>



So you see:




As you can see the tab <BR> causes the browser to put a newline wherever it encounters it. And as you have rightly guessed its one of those tags that do not have a closing pair (How can you have a closing tag for a newline character anyway!).


In summary:
<B></B> For Bold text
<I></I>     For Italic text
<U></U> For Underlined text
<BR>       A New-line character

No comments:

Post a Comment

Please leave a comment if you have anything to say or have something to ask.. I will do my best to answer..