Welcome our webmaster and SEO forum
Please enjoy the forum, contribute what you can, and wind up the Moderators!
Closed Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Differences between HTML & XHTML

  1. #1
    Resonate's Avatar
    Resonate is offline Internet Marketing Admin Resonate is a jewel in the rough Resonate is a jewel in the rough Resonate is a jewel in the rough
    Join Date
    Sep 2007
    Location
    {{ A Remote Server }}
    Posts
    536

    Default Differences between HTML & XHTML

    Summary of HTML to XHTML;
    • Tags must be properly nested: overlapping elements are not allowed
    • Tags and attributes must be in lower case
    • All elements must be closed
    • Attribute values must always be quoted
    • Attributes cannot be minimized: For example, <option selected> is incorrect it should be instead: <option selected="true">
    • ID attribute replaces the Name attribute
    • Mandatory elements: XHTML documents require certain mandatory elements. The html, head, body and title elements must exist. Additionally there must be a DOCTYPE declaration.
    The Most Important Differences:
    • 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
    XHTML Elements Must Be Properly Nested

    In HTML, some elements can be improperly nested within each other, like this:
    <b><i>This text is bold and italic</b></i>

    In XHTML, all elements must be properly nested within each other, like this:
    <b><i>This text is bold and italic</i></b>

    Note: A common mistake with nested lists, is to forget that the inside list must be within <li> and </li> tags.


    This is wrong:
    <ul>
    <li>Coffee</li>
    <li>Tea
    <ul>
    <li>Black tea</li>
    <li>Green tea</li>
    </ul>
    <li>Milk</li>
    </ul>
    This is correct:
    <ul>
    <li>Coffee</li>
    <li>Tea
    <ul>
    <li>Black tea</li>
    <li>Green tea</li>
    </ul>
    </li>
    <li>Milk</li>
    </ul>
    Notice that we have inserted a </li> tag after the </ul> tag in the "correct" code example.
    XHTML Elements Must Always Be Closed

    Non-empty elements must have an end tag.


    This is wrong:
    <p>This is a paragraph
    <p>This is another paragraph
    This is correct:
    <p>This is a paragraph</p>
    <p>This is another paragraph</p>
    Empty Elements Must Also Be Closed

    Empty elements must either have an end tag or the start tag must end with />.


    This is wrong:
    A break: <br>
    A horizontal rule: <hr>
    An image: <img src="happy.gif" alt="Happy face">
    This is correct:
    A break: <br />
    A horizontal rule: <hr />
    An image: <img src="happy.gif" alt="Happy face" />
    XHTML Elements Must Be In Lower Case

    The XHTML specification defines that the tag names and attributes need to be lower case.


    This is wrong:
    <BODY>
    <P>This is a paragraph</P>
    </BODY>
    This is correct:
    <body>
    <p>This is a paragraph</p>
    </body>
    XHTML Documents Must Have One Root Element



    All XHTML elements must be nested within the <html> root element. All other elements can have sub (children) elements. Sub elements must be in pairs and correctly nested within their parent element. The basic document structure is:
    <html>
    <head> ... </head>
    <body> ... </body>
    </html>
    Writing XHTML demands a clean HTML syntax.
    Some More XHTML Syntax Rules:
    • Attribute names must be in lower case
    • Attribute values must be quoted
    • Attribute minimization is forbidden
    • The id attribute replaces the name attribute
    • The XHTML DTD defines mandatory elements
    Attribute Names Must Be In Lower Case



    This is wrong:
    <table WIDTH="100%">
    This is correct:
    <table width="100%">
    Attribute Values Must Be Quoted



    This is wrong:
    <table width=100%>
    This is correct:
    <table width="100%">
    Attribute Minimization Is Forbidden



    This is wrong:
    <input checked>
    <input readonly>
    <input disabled>
    <option selected>
    <frame noresize>
    This is correct:
    <input checked="checked" />
    <input readonly="readonly" />
    <input disabled="disabled" />
    <option selected="selected" />
    <frame noresize="noresize" />
    Here is a list of the minimized attributes in HTML and how they should be written in XHTML:
    HTML Version XHTML Version
    compact
    compact="compact"
    checked
    checked="checked"
    declare
    declare="declare"
    readonly
    readonly="readonly"
    disabled
    disabled="disabled"
    selected
    selected="selected"
    defer
    defer="defer"
    ismap
    ismap="ismap"
    nohref
    nohref="nohref"
    noshade
    noshade="noshade"
    nowrap
    nowrap="nowrap"
    multiple
    multiple="multiple"
    noresize
    noresize="noresize"
    The id Attribute Replaces The name Attribute

    HTML 4.01 defines a name attribute for the elements a, applet, frame, iframe, img, and map. In XHTML the name attribute is deprecated. Use id instead.


    This is wrong:
    <img src="picture.gif" name="picture1" />
    This is correct:
    <img src="picture.gif" id="picture1" />
    Note: To interoperate with older browsers for a while, you should use both name and id, with identical attribute values, like this:
    <img src="picture.gif" id="picture1" name="picture1" />
    IMPORTANT Compatibility Note:
    To make your XHTML compatible with today's browsers, you should add an extra space before the "/" symbol.
    The Lang Attribute

    The lang attribute applies to almost every XHTML element. It specifies the language of the content within an element.
    If you use the lang attribute in an element, you must add the xml:lang attribute, like this:
    <div lang="no" xml:lang="no">Heia Norge!</div>
    Mandatory XHTML Elements

    All XHTML documents must have a DOCTYPE declaration. The html, head and body elements must be present, and the title must be present inside the head element.
    This is a minimum XHTML document template:
    <!DOCTYPE Doctype goes here>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Title goes here</title>
    </head><body>
    </body></html>
    Note: The DOCTYPE declaration is not a part of the XHTML document itself. It is not an XHTML element, and it should not have a closing tag.
    The XHTML standard defines three Document Type Definitions.
    The most common is the XHTML Transitional.
    <!DOCTYPE> Is Mandatory

    An XHTML document consists of three main parts:
    • the DOCTYPE
    • the Head
    • the Body
    The basic document structure is:
    <!DOCTYPE ...>
    <html>
    <head>
    <title>... </title>
    </head>
    <body> ... </body>
    </html>
    The DOCTYPE declaration should always be the first line in an XHTML document.
    An XHTML Example

    This is a simple (minimal) XHTML document:
    <!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title>simple document</title>
    </head>
    <body>
    <p>a simple paragraph</p>
    </body>
    </html>
    The DOCTYPE declaration defines the document type:
    <!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    The rest of the document looks like HTML:
    <html>
    <head>
    <title>simple document</title>
    </head>
    <body>
    <p>a simple paragraph</p>
    </body>
    </html>
    The 3 Document Type Definitions
    • DTD specifies the syntax of a web page in SGML.
    • DTD is used by SGML [COLOR=orange! important][COLOR=orange! important]applications[/color][/color], such as HTML, to specify rules that apply to the markup of documents of a particular type, including a set of element and entity declarations.
    • XHTML is specified in an SGML document type definition or 'DTD'.
    • An XHTML DTD describes in precise, computer-readable language, the allowed syntax and grammar of XHTML markup.
    There are currently 3 XHTML document types:
    • STRICT
    • TRANSITIONAL
    • FRAMESET
    XHTML 1.0 specifies three XML document types that correspond to three DTDs: Strict, Transitional, and Frameset.
    XHTML 1.0 Strict
    <!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    Use this when you want really clean markup, free of presentational clutter. Use this together with Cascading Style Sheets.
    XHTML 1.0 Transitional
    <!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    Use this when you need to take advantage of HTML's presentational features and when you want to support browsers that don't understand Cascading Style Sheets.
    XHTML 1.0 Frameset
    <!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
    Use this when you want to use HTML Frames to partition the browser window into two or more frames.
    -----------------------------------------
    Thanks to Resonate for this article
    BOO!!!!!! IM BACK!!!

    W3Poker Free Online Poker Strategy Blog : Poker Seo : Free Poker Money

  2. #2
    shaun is offline Junior Member shaun is on a distinguished road
    Join Date
    Nov 2007
    Posts
    15

    Default thankx

    thankx resonate.i just cleared my doubts by this.

  3. #3
    Resonate's Avatar
    Resonate is offline Internet Marketing Admin Resonate is a jewel in the rough Resonate is a jewel in the rough Resonate is a jewel in the rough
    Join Date
    Sep 2007
    Location
    {{ A Remote Server }}
    Posts
    536

    Default

    Quote Originally Posted by shaun View Post
    thankx resonate.i just cleared my doubts by this.
    Your Welcome
    BOO!!!!!! IM BACK!!!

    W3Poker Free Online Poker Strategy Blog : Poker Seo : Free Poker Money

  4. #4
    priji is offline Junior Member priji is on a distinguished road
    Join Date
    Jan 2008
    Posts
    10

    Default

    Thanks to share the briefly informations, very useful messages.

  5. #5
    forums is offline Junior Member forums is on a distinguished road
    Join Date
    May 2008
    Posts
    14

    Default

    Just to add something obvious (but not mentioned) XHTML is XML. HTML isn't!

  6. #6
    Gorkfu's Avatar
    Gorkfu is offline Senior Member Gorkfu is on a distinguished road
    Join Date
    May 2008
    Location
    USA
    Posts
    165

    Default

    XHTML is XML. HTML isn't!
    Isn't that sorta misleading? It should be XHTML is HTML4.0 + XML... It's not purely just XML.

  7. #7
    garima's Avatar
    garima is offline Junior Member garima is on a distinguished road
    Join Date
    May 2008
    Posts
    17

    Default

    XHTML is not very different from the HTML 4.01 standard.some difference between html and Xhtml is:-
    • 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

  8. #8
    dyamni is offline Junior Member dyamni is on a distinguished road
    Join Date
    Aug 2008
    Posts
    2

    Default

    Hi


    Thanks, to share this thing with me and also all of our web designer friends. This article sort out my queries, and also help me for choosing one of them.
    I choose XHTML, It is strict but i can handle it.

    thanks

  9. #9
    FreewareFreak is offline Junior Member FreewareFreak is on a distinguished road
    Join Date
    Aug 2008
    Posts
    13

    Default

    Quote Originally Posted by garima View Post
    XHTML is not very different from the HTML 4.01 standard.some difference between html and Xhtml is:-
    • 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
    And these rules are good. It brings order to the Web. I hate looking at a source code and finding that it does not follow standards.

  10. #10
    smeagain is offline Distinguished Member smeagain is on a distinguished road
    Join Date
    Jan 2008
    Posts
    263

    Default

    Whats missing is a list of advantages that would make it worthwhile to change from HTML to XHTML and a list of any disadvantages.

Closed Thread
Page 1 of 2 1 2 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Why using text/html for XHTML is bad
    By shaun in forum XHTML Forums
    Replies: 1
    Last Post: 12-20-2007, 09:39 PM
  2. If u Use XHTML
    By shaun in forum XHTML Forums
    Replies: 0
    Last Post: 11-30-2007, 11:06 AM
  3. URL Differences?
    By clangallacher in forum General Webmaster Talk
    Replies: 4
    Last Post: 11-08-2007, 07:24 AM
  4. The purpose of XHTML
    By ForumJoiner in forum General Webmaster Talk
    Replies: 6
    Last Post: 03-27-2007, 11:13 AM
  5. html 4.0 or xhtml 1.0 ?
    By OldDarkstarAccount in forum General Webmaster Talk
    Replies: 0
    Last Post: 01-08-2007, 02:08 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124