XHTML Tutorial
By now you should be familiar with the HTML markup lanuage and have some knowledge of XML. HTML displays and formats data. By using tags and attributes you can specify that this piece of text should be bold, another piece should be italic, this should be a heading, this section should be blue and so on.
HTML is a standardized markup language that allows documents all over the world to be defined using the same set of rules and codes so that they can all be read using the same type of program i.e. "Web Browser" such as Internet Explorer, Netscape or FireFox.)
However there are a number of problems with HTML
- Standards are not strictly adhered to
- The real meaning of a page is not neccessarily clear
- Data and structure are not separated
What is missing in HTML 4 is and its implementation is a sense of professionalism - a mechanism that would enforce the rules of the language and prevent WYSIWYG authoring tools from generating bad code. XML, a sister standard to HTML, provides this mechanism. If the syntax of an XML document is incorrect, if tags are improperly nested or if closing tags are missing, the structure of the XML document is considered not valid. When the rigorous standards of XML were applied to HTML it reformulated HTML and what emerged was XHTML 1.0.
XHTML will help to create documents that are valid, well-formed and more meaningful. This implies documents will be more relevant to a subject matter and will be more readily understood by humans and document readers.
Lets look at some of the XHTML rules and characteristics
- Formatting is permitted only via style sheets
- XHTML tags are all lowercase.
- XHTML is a stricter, tidier version of HTML.
- Pages written in XHTML work well in most browsers.
- All tags, including empty elements, must be closed.
- XHTML is the reformulation of HTML 4.0 as an application of XML.
- The elements (tags) and attributes are almost identical to HTML.
XHTML separates content from formatting. It does this by deprecating the style attribute and thus eliminating inline formatting. Instead, formatting is permitted only using CSS, which are referenced exclusively through the class and id attributes
When coding in XHTML keep the following in mind .
- Don't use formatting to convey meaning, only to empasise meaning. Use a generic tag like <span> or <div> with a meaningful class name. For example: <span class="important">Fuel prices soar by 15%</span>.
- Use CSS for formatting. Only external or embedded CSS, never inline CSS.
- Make sure that markup is well formed. This means all tags must be property nested and non-empty tags must have a closing tag. For example: <p>XHTML tutorial !</p>
- Empty elements like <br>, <hr>, <img>, etc. must end with a />. You can insert a space before the slash for backwards compatibility with older browsers. For example: <br /> and <hr />.
- Get into the habit of writing all element and attribute names in lowercase. XHTML 1.0 and higher requires this.
- Make sure all attribute values have quotes around them. For example:
<div id="header">.
Have not found what you looking for, try searching Google. Simply use the search box below: