|
Tips For Coding xHTML |
In XHTML, there are tags that need to be included in your code in order for the browser to render the files correctly. Your code should always include:
- A !doctype tag:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- An open and closed html tag:
<html> and </html>
- An open and closed title tag (within the head tag):
<title> and </title>
Be sure when you are adding the title of the document into the <title> that you copy and paste it. The title
of the document must be visible in both the browser title bar and the body of the page.
- An open and closed body tag:
<body> and </body>
When using frames, you must use the frameset !doctype tag (only on pages that contain framset and frame tags):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
TIPS FOR CODING WITH XHTML TAGS
- All tags must be in lower case.
- Each time you open a tag (<p>) you must close the tag (</p>).
- Tags must be nested properly:
CORRECT: <p><strong>example</strong></p>
INCORRECT: <p><strong>example</p></strong>
- Structural tags include things like <html> </html>, <head> </head> and <body> </body>
- Head Tags are tags that are found in the <head> </head> such as the <title> </title>.
- Block-level tags are tags that format your text like <p> </p>.
- Text-level tags are tags that format your words like <strong> </strong> to bold words.
- Stand alone tags are tags such as <br /> and <hr /> that need to be closed.
- All attributes must be double quoted (<body bgcolor="#FFFFFF"> </body>).
- Make sure that you use your attributes correctly:
CORRECT: <p align="center">
My page
</p>
WRONG: <p align = " center " >
My page
</p align="center">
- Always use the height="" width="" alt="" and border="" attributes while working with images even if they are zero (0).
- Make sure you always have the same amount of frame tags as rows or columns, as specified in your frameset tag.
|
|
| |