This document was uploaded by user and they confirmed that they have the permission to share
it. If you are author or own the copyright of this book, please report to us by using this DMCA
report form. Report DMCA
Introduction The flexibility of the layout of a webpage is very limited if HTML is used solely. The layouts, for example the page margins, the indentation, etc, can only be specified by using the style which will not be discussed in this chapter. Despite of the limited ability of HTML, we can still define a heading, a paragraph, insert a new-line character, align texts and create different kind of list. Line Break and Paragraph In most situations, when we are editing text in a word processor, we expect the text to start in a new line by pressing the Enter button. However, this is not the case in HTML editing. A new line character in the HTML code does not imply the same in the rendered web page. Try the following code and describe what you see in the browser: New Line Demonstration We want to test the new line character in HTML file. Will this line appear in another line?
If we want to start our text in a new line, we have to use the following tags. 1.
Heading – Tag is a tag used to mark the enclosed text as a heading (bold), ranging from most prominent to least prominent. A new line character is inserted after the tag. Usage: Text where n can be 1, 2, 3, 4, 5 or 6
Example:
Most prominent heading
Least prominent heading
2.
Manual Line Break – Tag is inserted into the text where the following text should be shown in the next line. Note that only has the end tag. Usage: Text
Example: Can you give me a hand? Sure!
F.4 CIT – HTML – Text: Layout
3.
page 2
Paragraph –
Tag Paragraphs are delimited by the paragraph tag,
.
tag controls the line spacing within the paragraph as well as the line spacing between paragraphs. The default line spacing is single space within a paragraph and double-space between paragraphs. What is the difference between
tag and tag? Usage:
Text
Example:
Can you give me a hand?
Sure!
4.
Preserving Formatting –
Tag Sometimes, you will want the client browser to interpret the text as appeared in the HTML, including the white spaces and forced formatting. In such cases, we can use the preformatted tag,
. This tag tells the browser that the text within the tag has been preformatted and should be rendered exactly as it appears in the code. The enclosed tag is rendered in a monospaced font. Usage: <pre>Text
Example: <pre>Can you give me a hand? Sure!
5.
Line Break – Tag tag causes the browser to draw a line between the component before and after the tag. Usage: Component 1Component 2
Attributes: align:
It can be left | center | right.
noshade:
No shading effect on the line
size:
The line size measured in pixel
width:
The line width measured in pixel or percentage (relative)
Example: Heading Here Content Here
F.4 CIT – HTML – Text: Layout
page 3
Text Alignment The alignment of text can be specified in the attributes of many tags. The attribute name is align and its possible values are CENTER, LEFT and RIGHT. Usage: align