2--Text-Elements
2--Text-Elements
T. Samih Mohamed
E.mail [email protected]
XHTML Text Elements
An XHTML element is a component of an XHTML document. It is typically
comprised of a start tag, an end tag, and some web content in between the
start and end tag.
We've already learned about the <html>, <head>, <body>, <meta>, and
<title> elements. Now let's learn some elements that we'll use to present
actual text content on our web page:
<p> Paragraph
<br> Line Break
<hr> Horizontal Rule
<h1> - <h6> Headings
<ul> Unordered List
<ol> Ordered List
<li> List Item
The <p> Element
The standard way of presenting blocks of text in an XHTML document is to
use the <p> ("paragraph") element:
<body>
<p>This is a paragraph of text. We can make it as long as we
wish. The browser will automatically wrap the lines to accommodate the
size of the browser window.</p>
<p>This is the second paragraph of text.</p>
</body>
Heading elements add blank lines before and after the text, just like <p> does.
The <h1> element - often referred to as the main heading - indicates the most
important heading and should be used no more than once per page.
The role of XHTML is to define and organize content, not to format it. Heading elements
should not be used as a way to bold words on the page. Rather, they should be used to
define the relative importance of content. Thus, <h2> is more important than <h3>.
Lower elements (e.g. <h4>) can be used, even if higher ones (e.g. <h3>) haven't.
The <ul> Element
The <ul> element ("unordered list") creates an indented bullet point list of items:
<body>
<p>Fruit in Alphabetical Order:</p>
<ul>
<li>Apples</li>
<li>Bananas</li>
<li>Cantaloupes</li>
</ul>
</body>
The <li> element ("list item") is used for each individual item in a list. They are
all nested within the <ul> tags.
By default, the list items are shown with bullet points, but this can be changed to squares,
circles, or other graphics using CSS, which we will learn later in the course.
The <ol> Element
The <ol> element ("ordered list") creates an indented list of numbered items:
<body>
<p>Fruit in Alphabetical Order:</p>
<ol>
<li>Apples</li>
<li>Bananas</li>
<li>Cantaloupes</li>
</ol>
</body>
The <ol> element works identically to the <ul> element. The only difference is
whether the listed items are shown with bullet points or numbers.
By default, the list items show with incrementing numbers. By using CSS, we can
change this to letters or Roman numerals.