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 

A collection of 18 FAQs/tutorials tips on XHTML body tag and block level tags. Clear answers are provided with tutorial exercises on XHTML body element and its sub-elements; normal paragraphs and pre-formatted paragraphs, in-line elements in paragraphs, line breaks and paragraph spacing, block level elements: p, pre, blockquote, h1, hr. Topics included in this collection are:

  1. What Is the Body Tag/Element?
  2. What Is Wrong with My Body Elements?
  3. What Elements Are Allowed as Body Sub-Elements?
  4. What Attributes Are Allowed in the Body Element?
  5. What Is a P Tag/Element?
  6. Can I Mix Images with Text in a Paragraph?
  7. How To Control Line Breaks in a Paragraph?
  8. How To Highlight One Part of a Paragraph?
  9. How To Get Extra Space between Paragraphs?
  10. What Is Wrong with My P Elements?
  11. What Is a PRE Tag/Element?
  12. Are Tab Characters Preserved in a PRE Element?
  13. Can Images Be Included in PRE Elements?
  14. What Is a BLOCKQUOTE Tag/Element?
  15. Can BLOCKQUOTE Elements Be Nested?
  16. What Are Heading Tags/Elements?
  17. What Are HR Tags/Elements?
  18. What Are Other Block Elements?

Please note that all notes and tutorials are based on XHTML 1.0 specification.

What Is the Body Tag/Element?

The body element is used to provide content of the XHTML document. Here are some rules about the body tag/element:

  • The body element is a second level element. The body element must be the second child element of the html element.
  • You can only place a single body element in an XHTML document.
  • The body element must be coded with the body opening tag, <body>, and the body closing tag, </body>.
  • The body element can not be empty. The body must have one or more block-type elements
  • The body element can not have any text information directly included between the opening and closing tags.

What Is Wrong with My Body Elements?

If you are having trouble with your body elements, it could be caused by one of the following common mistakes:

 <!-- Text can not be used in body directly -->
 <body>
  Hello world!
 </body>

 <!-- "title" is not allowed in body element -->
 <body>
  <title>XHTML FAQ</title>
 </body>
 
 <!-- "img" is not a block level eleent -->
 <body>
  <img src="images/fyi.gif" alt="FYI" />
 </body>

 <!-- "p" element is missing closing tag -->
 <body>
  <p>Welcome to FYIcenter.com!
 </body>

 <!-- body element can not be empty -->
 <body>
 </body>

What Elements Are Allowed as Body Sub-Elements?

The content model of the body element is sub-element only. Character data is not allowed as body element's content. You can only enter sub elements inside the body element. But not all elements can be entered inside the body element. Strict XHTML document only allow block type elements to be included directly inside the body element.

Here are some commonly used block type elements:

  • p - Specifying paragraphs of text.
  • pre - Specifying pre-formatted text.
  • blockquote - Specifying quoted paragraphs of text.
  • h1, h2, h3, h4, h5, h6 - Specifying headings of different levels.
  • hr - Specifying horizontal rules.
  • ul, ol, dl - Specifying lists of items.
  • table - Specifying tables of columns and rows.
  • form - Specifying forms with input fields.
  • script - Specifying client-side script codes.
  • div - Specifying structural divisions.

(Continued on next part...)

Part:   1   2  3  4  5  6 


Selected Developer Jobs:

More...