Mga Pahina

Linggo, Enero 23, 2011

Basic in XHTML



Now that you know HTML, here are some things to know about XHTML:

XHTML elements must be properly nested. The following code is allowed in HTML but not in XHTML:
                <b><i>This is coll!</b></i>
Always keep in mind that whatever comes first must be closed last. The following code is accepted in XHTML.
                <b><i>This is cool!   </i></b>
XHTML elements must always be closed. The following examples are accepted in HTML but not in XHTML:
                <br> This is a line break
                <hr> This is a horizontal line
Instead, the following codes are accepted in XHTML.
                This is a line break <br>
                This is a horizontal line</hr>

Notice the backslash after the elements tag.

XHTML elements must be in lowercase. The following examples is accepted in HTML but not in XHTML:
                <body>
                <p>This is a paragraph</p>
                <BODY>
Instead,  the following codes are accepted in XHTML:
            <body>
            <p> This is a paragraph</p>
           </body>

XHTML Attributes must be in lowercase. The following example is accepted in HTML but not in XHTML:
          <table HEIGTH=”84%”>
Instead, the following code is accepted in XHTML.
         <table height=”84%”>
XHTML attributes values must be quoted. The following example is not accepted in XHTML:
<table height=84%>
Instead, the following code is accepted in XHTML.
<table height=”84%”>

Instead, of using the Id attribute, use the name attribute. The following code is accepted in XHTML:
<img src=”pic1.jpg” id=”pic1” />

XHTML documents must have a DOCTYPE declaration. The html, head, title and body elements must be included in all the documents.

Sample code:

<!DOCTYPE html PUBLIC “-//W3C//DD  XHTML 1.0Strict//EN””http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
<html>
<title>Example1</title>
</head>
<body>
<p>This is my body</p>
</body>
</html>

Use the DOCTYPE! Declaration if you want your web pages to be validated as XHTML documents.

There are three XHTML document types:
STRICT - type is used together with Cascading Style Sheets (to be discussed later). It uses the following structure:

<!DOCTYPE html PUBLIC “-//W3C//DD  XHTML 1.0Strict//EN””http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

TRANSITIONAL type is used whenever a certain web browser does not understand Cascading Style Sheets. It uses the following structure:

<!DOCTYPE html PUBLIC “-//W3C//DD  XHTML 1.0Stransitional//EN””http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

FRAMESET type is used whenever you want to use HTML frames to partition the web pages. This type uses the following structure:

<!DOCTYPE html PUBLIC “-//W3C//DD  XHTML 1.0 Frameset //EN””http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>


Walang komento:

Mag-post ng isang Komento