YouTip LogoYouTip

Html Xhtml

## Differences Between XHTML and HTML ### Document Structure * XHTML DOCTYPE is mandatory * The xmlns attribute in `` is mandatory * ``, ``, ``, and `<body>` are also mandatory ### Element Syntax * XHTML elements must be properly nested * XHTML elements must always be closed * XHTML elements must be in lowercase * XHTML documents must have one root element ### Attribute Syntax * XHTML attribute names must be in lowercase * XHTML attribute values must be quoted * XHTML attribute minimization is forbidden * XHTML images must have an alt attribute --- ## XHTML Documents Must Have a DOCTYPE Declaration An XHTML document must have a DOCTYPE declaration. The complete XHTML document structure is as follows: ```html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <title>Document title Document content ``` --- ## XHTML Elements Must Be Properly Nested In HTML, some elements can be improperly nested within each other, like this: ```html This text is bold and italic ``` In XHTML, all elements must be properly nested within each other, like this: ```html This text is bold and italic ``` --- ## XHTML Elements Must Always Be Closed In HTML, some elements may not have a closing tag, like this: ```html

This is a paragraph

This is another paragraph ``` In XHTML, all elements must be closed, like this: ```html

This is a paragraph

This is another paragraph

``` **Empty elements must also be closed:** ```html A line break:
A horizontal rule:
An image: Happy face ``` --- ## XHTML Elements Must Be in Lowercase In HTML, tags and attributes can be uppercase or lowercase, like this: ```html

This is a paragraph

``` In XHTML, tags and attributes must be in lowercase: ```html

This is a paragraph

``` --- ## XHTML Attribute Names Must Be in Lowercase In HTML, attribute names can be uppercase or lowercase, like this: ```html ``` In XHTML, attribute names must be in lowercase: ```html
``` --- ## XHTML Attribute Values Must Be Quoted In HTML, attribute values may not be quoted, like this: ```html
``` In XHTML, attribute values must be quoted: ```html
``` --- ## XHTML Attribute Minimization Is Forbidden In HTML, some attributes can be minimized, like this: ```html