|
Home >> FAQs/Tutorials >> XHTML Tutorials and Tips >> Index
XHTML 1.0 Tutorials - Body Tag and Block Level Tags
By: FYICenter.com
Part:
1
2
3
4
5
6
(Continued from previous part...)
What Attributes Are Allowed in the Body Element?
XHTML 1.0 strict version does not allow some attributes that were
commonly used in early versions of HTML specification. For example: "background"
can be used to specify a background image, and "bgcolor" can be used to specify
the background color.
Both "background" and "bgcolor" are not allowed as "body" attributes now.
If you want set background image and color, you need to use the "style"
attribute to specify CSS properties, as shown the tutorial example below:
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Style Attribute in Body Element</title>
</head>
<body style="background-color: #dddddd">
<p>Hello world!</p>
</body>
</html>
If you save the above document as style.html, and view it with
Internet Explorer, you will see a gray background specified
by the style attribute as shown below:

What Is a P Tag/Element?
A p element is a block level element that can be used directly as
a sub-element in the body element. You can use p elements to specify
paragraphs of text and in-line elements. Here are basic rules about
p elements:
- "p" elements are mixed content elements.
- "p" elements can have empty contents.
- "p" elements can have PCDATA as contents.
- "p" elements can have in-line elements as contents.
- "p" elements can not have block elements as contents.
- "p" elements can not have "p" elements as contents.
- "p" elements are block elements. They can not be used as in-line elements.
- "p" elements will be displayed by browsers as paragraphs with some leading
and trailing vertical spaces.
Here is a good example of p elements:
<p>Learning XHTML is like learning any new language,
computer or human. Most students first immerse themselves
in examples. Studying others is a natural way to learn,
making learning easy and fun.</p>
Can I Mix Images with Text in a Paragraph?
Yes. "img" elements are in-line elements. You can use "img" elements
to mix images with text in any paragraph defined by a "p" element'.
Below is a good tutorial example of image mixed with text:
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>The XHTML Validation Icon</title>
</head>
<body>
<p>If you know your Web page is a valid XHTML document,
you should include this image, <img
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0 Strict" height="31" width="88" />
on your page to show your readers that
you have taken care to create an interoperable page.</p>
</body>
</html>
If you save the above document as validator.html, and view it with
Internet Explorer, you will see an image icon mixed nicely with other
text in a paragraph as shown below:

(Continued on next part...)
Part:
1
2
3
4
5
6
|