Search Helium

Home > Computers & Technology > Internet > Web Design

Formatting text in XHTML

by Chrys

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

Helium Debate

Cast your vote!

Should anyone have to pay to use Facebook?

Click for your side.

130384

Featured Partner

1H2O

1H2O endeavors to create an international network of journalists and media makers with the purpose of generating the most compelling journalism relating to water and human life. 1H2O is a collaboration between the Knight Center for ...more


CONNECT WITH US

Read
our blog
Helum for writers

Write and get published
Share with other writers
Polish your freelancing skills

Join our active writing community
Helium Content Source for Publishers

Quality articles from proven freelancers
Exclusive rights, fast turnaround
Brand engagement, business blogging -- our writers do it all

Get custom content today!

INFORMATION


Helium, Inc.
200 Brickstone Square Andover, MA 01810 USA
#