Home >> FAQs/Tutorials >> XHTML Tutorials and Tips >> Index

XHTML Tutorial - XHTML Element Content Models

By: FYIcenter.com

(Continued from previous topic...)

What Are the XHTML Element Content Models?

There are 4 content models defined for XHTML elements:

1. EMPTY - No content. Nothing between the opening tag and the closing tag. For example:

  <br/> - "br" element has no content.
  <br></br> - Same as above.
  <meta name="Author" content="FYICenter.com"/>

2. PCDATA - Parsed Character DATA. A string of characters and character entities. Empty content is allowed in this model. But no other XHTML elements are allowed in the content.

  <!-- PCDATA: Pure character string -->
  <title>My First XHTML Document</title>

  <!-- PCDATA: Empty string -->
  <textarea rows="4" cols="40"></textarea>  

  <!-- PCDATA: Characters mixed with entities -->
  <textarea rows="4" cols="40">
    while ($i=0; $i&lt;3; %i++) print "Knock ";
  </textarea>  

3. Sub-elements only - A sequence of sub-elements. No character strings are allowed in the content.

 <!-- Sub-elements only: 
   "head" can only take sub-elements like "title"
   and "meta" -->
 <head>
  <title>My First XHTML Document</title>
  <meta name="Author" content="FYICenter.com"/>
 </head>

 <!-- Sub-elements only: 
   "tr" can only take sub-elements like "td" -->
 <tr>
  <td>Author:</td>
  <td>FYIcenter.com</td>
 </tr>

 <!-- Sub-elements only: 
   "ul" can only take sub-elements like "li" -->
 <ul>
  <li>My First XHTML Document</li>
 </ul>

4. Mixed - A mixture of PCDATA and sub-elements. Empty content is also allowed in this model.

 <!-- Mixed content: "p" is having 
   text strings mixed  an "em" element -->
 <p>The nature of <em>yin and yang</em> is relative.</p>

 <!-- Mixed content: "td" is having
   text strings mixed with a "p" element -->
 <td>Dear Visitor,
  <p>Welcome to FYIcenter.com!</p>
  Thank you.
 </td>

(Continued on next topic...)

  1. What Is the XHTML Element Content?
  2. What Are the XHTML Element Content Models?
  3. What Are the XHTML Elements Defined with EMPTY Contents?
  4. What Are the XHTML Elements Defined with PCDATA Contents?
  5. What Are the XHTML Elements Defined with Sub-elements Contents?
  6. What Are the XHTML Elements Defined with Mixed Contents?
  7. What Is PCDATA?
  8. What Is an XHTML Entity?
  9. What Is CDATA?
  10. What Is a Sub-element?
  11. Can Two Elements Partially Overlap Each Other?
  12. What Is the Sequence of Sub-elements?
  13. What Is a Required Sub-element?
  14. What Is a White Space Character?
  15. How Exactly White Space Characters Are Ignored?
  16. How To Get an Extra White Space?


Selected Developer Jobs:

More...