Home > Computers & Technology > Internet > Web Design
Created on: March 07, 2009 Last Updated: March 11, 2009
XHTML Basics - Part 5
Introduction Formatting text refers to the ways of presenting text. For example, you may want to have text underline or bold. When you are writing a poem, you would want to put text in particular position on the line of the page; this is also a case of formatting.
Formatting text with XHTML You can do limited formatting with XHTML. You are not even advised to do serious formatting with XHTML. If you think that your web page needs a lot of formatting (presentation), use what is called Cascaded Style Sheet. Cascaded Style sheet will not be covered in this series. Everything being equal, I will teach you that in a different series. What I give you in this part of the series, is what you can use to format text using XHTML. If you want more power, you would have to use Cascaded Style Sheet.
Characters of Text Try the following Code (save and open in browser).
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> </head> <body> <b>This text is bold</b><br /><br /> <big>This text is big</big><br /><br /> <strong>This text is strong</strong><br /><br /> <small>This text is small</small><br /><br /> <i>This text is italic</i><br /><br /> <em>This text is emphasized</em><br /><br /> This text is <sub>subscript</sub><br /><br /> This text contains <sup>superscript</sup><br /><br /> </body> </html>
What interest us here, is what is in the Body element of the web page code. There are eight lines in the Body element. I assume that you have tried the code.
In your browser, you should see the first line bold. To bold text, use the B tag pair as follows:
<b>This text is bold</b>
If you look at the code, you would notice that after each of the eight lines you have a pair of line-break elements. The first line-break element of the pair, forces anything on its right to the next line at the browser. The second line break element forces anything that is to appear on its right to the next line. Since there was nothing on its left, a new line is created below the previous line of text at the browser. The other pairs of line break elements behave in the
Below are the top articles rated and ranked by Helium members on:
Formatting text in XHTML