Basic Text Formatting
Table of Content:
Because almost every document you create will contain some form of text, the elements you are about to meet are likely to feature in most pages that you will build. In this section, you learn how to use what are known as basic text formatting elements:
< h1 > , < h2 > , < h3 > , < h4 > , < h5 > , < h6 >
< p > , < br / > , < pre >
White Space and Flow
Basic Text Formatting
This section is going to address the way in which you mark up text. Almost every document you create will contain some form of text, so this will be a very important section.
Whitespace and Flow
Before you start to mark up your text, it is best to understand what XHTML does when it comes across spaces and how browsers treat long sentences and paragraphs of text.
Creating Headings Using hn Elements
No matter what sort of document you are creating, most documents have headings in some form or other...
Live Preview
Paragraph
A Short Story : The Golden Egg
This Short Story The Golden Egg is quite interesting to all the people. Enjoy reading this story.
Haria, a poor barber lived alone in his small hut. He was dedicated to his work. And whatever he earns was enough to fulfill his needs.
One evening, after returning from work, Haria was hungry. “What shall I cook tonight?" he thought. Just then he heard a hen clucking outside his hut. "That hen would make a great feast for me," thought Haria and prepared to catch the hen.
With a little effort he was able to catch the hen. As he was about to kill the hen, it squeaked, "Please do not kill me, O kind man! I will help you." Haria stopped. Though he was surprised that the hen spoke, he asked, "How can you help me?"
If you spare my life, I will lay a golden egg everyday for you," said the hen. Haria’s eyes got widened in delight. Haria was surprised to hear this promise. “A golden egg! That too everyday! But why should I believe you? You might be lying," said Haria. “If I do not lay a golden egg tomorrow, you can kill me," said the hen. After this promise, Haria spared the hen and waited for the next day.
The next morning, Haria found a golden egg lying outside his hut and the hen sitting beside it. “It is true! You really can lay a golden egg!" exclaimed Haria with great delight. He did not reveal this incident to any one, fearing that others would catch the hen.
From that day onwards, the hen would lay a golden egg everyday. In return, Haria took good care of the hen. Very soon, Haria became rich.
But he became greedy. He thought, "If I cut open the hen’s stomach, I can get out all the golden eggs at once. I do not have to wait for the hen to lay the golden eggs one by one."
That night, he brought the hen to the interior portion of his house and killed the hen. But to his dismay, he found no golden eggs. Not even one.
"What have I done? My greed had made me kill the hen, "he wailed. But it was too late.
Live Preview
The align
Attribute
Value | Meaning |
left | The heading is displayed to the left of the browser window (or other containing element if it is nested within another element). This is the default value if the align attribute is not used. |
center | The heading is displayed in the center of the browser window (or other containing element if it is nested within another element). |
right | The heading is displayed to the right of the browser window (or other containing element if it is nested within another element). |
Here is an example of using the deprecated align
attribute
Left-Aligned Heading
This heading uses the align attribute with a value of left.
Centered Heading
This heading uses the align attribute with a value of center.
Right-Aligned Heading
This heading uses the align attribute with a value of right.
Live Preview
Creating Line Breaks Using the <br>
Element
When you want to start a new line you can use the line break element. So, the next
Paragraph one
word will appear on a new line.
Paragraph two
Paragraph three
Creating Preformatted Text Using the <pre>
Element
Sometimes you want your text to follow the exact format of how it is written in the HTML document — you don ’ t want the text to wrap onto a new line when it reaches the edge of the browser; you don ’ t want it to ignore multiple spaces; and you want the line breaks where you put them.
void main() { int a, b, c; a=2; b=3; c=a+b; printf("%d",c) }
Any text between the opening <pre>
tag and the closing <pre>
tag will preserve the formatting of the
source document. You should be aware, however, that most browsers would display this text in a
monospaced font by default. (Courier is an example of a monospaced font, because each letter of the
alphabet takes up the same width. In non - monospaced fonts, an i is usually narrower than an m .)