SitePoint Sponsor

User Tag List

Results 1 to 25 of 35

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Location
    Kolkata, India
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question HTML and XHTML - Some Basic Question

    I'm a website developer. I've developed number of websites, but believe me, I'm not aware of some basic definitions of HTML and XHTML. I realize, many coder on date are doing good job in website development, but they also don't know this basic differences, as these are not greatly associated with practical aspects.

    Folks, can you please help me (and those coders) to find out the answers to these basic questions?


    1. What is the difference between HTML and XHTML?

    2. What is used, HTML or XHTML, when we're designing basic webpages?

    3. What is the difference between XHTML 1.0 Transitional and XHTML 1.0 Strict?

    4. We used to write this piece of code on top of every webpage. Can you please explain word by word, what this 2 lines of code mean?

    HTML Code:
    <!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">
    $0.50/Mo for 500MB Web hosting Kolkata
    Web design in Kolkata
    Website development company in Kolkata

    Hostgator 25% Discount Coupon wow25percent

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1, The basic differences are listed here: html & xhtml
    2, XHTML is recommended

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    3, Strict and Transitional specifies the CSS support type, strict is formally the browser independent support of basic CSS 1.0 properties, but in real life ...

    4. doctype spec: http://help.dottoro.com/lhlsvbgj.php
    Gumape

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gumape View Post
    1, The basic differences are listed here: html & xhtml
    Those are merely the superficial differences. You don't even mention the whole MIME type thing!

    Quote Originally Posted by gumape View Post
    2, XHTML is recommended
    How can you recommend a markup language that isn't supported by the browsers that 60-90&#37; of the population is using?

    Quote Originally Posted by gumape View Post
    3, Strict and Transitional specifies the CSS support type, strict is formally the browser independent support of basic CSS 1.0 properties, but in real life ...
    Pardon? The DTDs have nothing to do with 'the CSS support type' (whatever that is). Transitional DTDs are meant to be used in a transitional (duh!) phase when modernising pre-HTML4 documents. It's not intended to be used for creating new documents.

    Quote Originally Posted by gumape View Post
    The DTD specifies the syntax of the document and affects the visual appearance of the page.
    I'd be interested to know how you think that the DTD affects the visual appearance of the page.

    It specifies the markup grammar, that's true. And that's all.

    The presence and format of a doctype declaration in an HTML document (including pretend-XHTML) does affect the rendering mode in modern browsers.

    XHTML, being an application of XML, is always rendered in standards mode. Provided it's served with a MIME type that is recognised as being an XML document, of course. Otherwise it isn't XHTML at all.
    Birnam wood is come to Dunsinane

  4. #4
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    I'd be interested to know how you think that the DTD affects the visual appearance of the page.
    I think he means that the switch from quirks to standard can affect the visual appearence in terms of the bugs and problems that can occur in quirks mode as per how Internet Explorer seems to soil itself every now and again when we try and suprise it

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AlexDawson View Post
    I think he means that the switch from quirks to standard can affect the visual appearence in terms of the bugs and problems that can occur in quirks mode as per how Internet Explorer seems to soil itself every now and again when we try and suprise it
    The DTD has nothing to do with that. That's the doctype declaration (or the lack thereof) in the document itself. Browsers don't read DTDs, as a rule.
    Birnam wood is come to Dunsinane

  6. #6
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,243
    Mentioned
    239 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    The DTD has nothing to do with that. That's the doctype declaration (or the lack thereof) in the document itself. Browsers don't read DTDs, as a rule.
    I would go a bit further here... it is the DOCTYPE declaration, the lack of it or if the declaration is incomplete.

  7. #7
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by techbongo View Post
    1. What is the difference between HTML and XHTML?
    XHTML 1.0 is nothing but a reformulation of HTML 4.01 as an application of XML 1.0.
    See the XHTML vs HTML FAQ for more details.

    Quote Originally Posted by techbongo View Post
    2. What is used, HTML or XHTML, when we're designing basic webpages?
    HTML, usually. Microsoft Internet Explorer doesn't support XHTML, which makes XHTML rather unusable for public sites.

    Note that many (probably a majority by now) believe that they use XHTML, but they don't. Merely writing XHTML-style markup doesn't make it XHTML, as explained in the aforementioned FAQ.

    The recommended markup language is HTML 4.01 Strict (not XHTML, as gumape claims).

    Quote Originally Posted by techbongo View Post
    3. What is the difference between XHTML 1.0 Transitional and XHTML 1.0 Strict?
    The Transitional DTD allows the use of a number of element types and attributes that are deprecated in the Strict DTD. Those are mainly presentational and should be handled via CSS, or affect behaviour and should be done with JavaScript.

    XHTML 1.0 Transitional is a curious abomination whose raison d'Ítre eludes me.

    Quote Originally Posted by techbongo View Post
    4. We used to write this piece of code on top of every webpage. Can you please explain word by word, what this 2 lines of code mean?
    The first line is the document type declaration, which tells interested parties to which document type definition (DTD) the document claims conformance. Browsers normally don't care, since they use non-validating parsers. Nowadays they do look at the doctype declaration, but only to decide whether it's a reasonably 'modern' or 'old-school' document, which affects the rendering mode.

    The doctype declaration is mainly meant for markup validators.

    The second line is the start tag for the root element of the document. It must always be <html> in HTML and XHTML (although HTML is not case-sensitive). The xmlns attribute is for XHTML only and tells the user agent that this is an XHTML document, as opposed to any other flavour of XML. One might think that the doctype declaration does that, but that's not the case. The doctype declaration is optional; the xmlns attribute is required for XHTML and must have the exact value you quoted.
    Birnam wood is come to Dunsinane

  8. #8
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Location
    Kolkata, India
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh!!! The thread has become interesting.
    This is why I mentioned, that many of us are good coders even with this misconceptions. I'll like to know the fact of DTD.

    Quote Originally Posted by AutisticCuckoo View Post
    XHTML 1.0 is nothing but a reformulation of HTML 4.01 as an application of XML 1.0.
    See the XHTML vs HTML FAQ for more details.


    HTML, usually. Microsoft Internet Explorer doesn't support XHTML, which makes XHTML rather unusable for public sites.

    Note that many (probably a majority by now) believe that they use XHTML, but they don't. Merely writing XHTML-style markup doesn't make it XHTML, as explained in the aforementioned FAQ.

    The recommended markup language is HTML 4.01 Strict (not XHTML, as gumape claims).


    The Transitional DTD allows the use of a number of element types and attributes that are deprecated in the Strict DTD. Those are mainly presentational and should be handled via CSS, or affect behaviour and should be done with JavaScript.

    XHTML 1.0 Transitional is a curious abomination whose raison d'Ítre eludes me.


    The first line is the document type declaration, which tells interested parties to which document type definition (DTD) the document claims conformance. Browsers normally don't care, since they use non-validating parsers. Nowadays they do look at the doctype declaration, but only to decide whether it's a reasonably 'modern' or 'old-school' document, which affects the rendering mode.

    The doctype declaration is mainly meant for markup validators.

    The second line is the start tag for the root element of the document. It must always be <html> in HTML and XHTML (although HTML is not case-sensitive). The xmlns attribute is for XHTML only and tells the user agent that this is an XHTML document, as opposed to any other flavour of XML. One might think that the doctype declaration does that, but that's not the case. The doctype declaration is optional; the xmlns attribute is required for XHTML and must have the exact value you quoted.
    Thank you AutisticCuckoo and all other poster for your replies. Let me read these pages carefully. I'm sure, I'll have more questions on the way.
    $0.50/Mo for 500MB Web hosting Kolkata
    Web design in Kolkata
    Website development company in Kolkata

    Hostgator 25% Discount Coupon wow25percent

  9. #9
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,836
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by techbongo View Post
    I'll like to know the fact of DTD.
    Web browsers ignore DTDs. Except if you are validating the page using a validator that uses the DTD reference to determine which version of HTML or XHTML to validate the page as you can leave that part out. The SGML standard states that those parts of the doctype are optional. The only part that is required (to stop all browsers displaying the page differently from one another) is <!DOCTYPE html> (that is valid for HTML 2+ and all versions of XHTML).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  10. #10
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    www.w3schools.com/html/
    Try this one
    This site is really helpful.

  11. #11
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,836
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by virtualmisc View Post
    www.w3schools.com/html/
    Try this one
    This site is really helpful.
    Really out of date since the two guys who built it have moved on to other things.

    http://webdesign.about.com is a far better site for learning about HTML and XHTML and it (unlike w3schools) is being constantly updated with more information.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  12. #12
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Off Topic:

    someone seems to be keeping w3schools' javascript pages more up to date... or, they just seem newer and seem to have more recent stuff in them than the markup area...

  13. #13
    SitePoint Addict SilentBobSC's Avatar
    Join Date
    Mar 2005
    Location
    South Carolina
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, first you want to declare your doctype if for no other reason than making your life troubleshooting those annoying cross-browser inconsistencies a little easier.

    I personally have to use a XHTML 1.0 Transitional doctype for many of my projects because I work with a Content Managment System (Dotnetnuke) and because of all the variations between third-party modules, I find it much easier to validate and correct visual issues.

    As many have stated though, most of the differences are in your tag formatting and attributes, for instance: XHTML does not allow for your tags to be capitalized, the browsers don't care but the validator does. There are also limitations placed on which tags can use which attributes, the most popular being the EMBED/OBJECT tags used for embedding flash elements. ( I use this method myself.)

    Basically, my understanding is HTML is your basic markup, whereas XHTML represents more of an 'Application' that includes more XML-like elements and markup.

    I am open for correction, however.

  14. #14
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,836
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by SilentBobSC View Post
    Basically, my understanding is HTML is your basic markup, whereas XHTML represents more of an 'Application' that includes more XML-like elements and markup.
    I'll supply the correction.

    HTML and XHTML are two completely different web languages. XHTML requires everything to pass validation or the page will not display at all and so you have to make sure your page is completely valid if you use XHTML. Also Internet Explorer can't process XHTML and so if you want to allow your visitors to use Internet Explorer then you can't use XHTML.

    You can use either an HTML or XHTML doctype with HTML (provided you limit yourself to the subset of XHTML that is just slightly badly formed HTML so that the browsers can still process it as HTML. You must use an XHTML doctype if you are going to use XHTML.

    You can usually tell what language is really being used by looking at an image tag.

    <img src=picture.gif> is HTML
    <img src="picture.gif" /> is usually HTML (with an XHTML doctype)
    <img src="picture.gif"/> is XHTML (the lack of a space before the slash would make the preceding attribute invalid as HTML but the space isn't needed in XHTML).

    Another example of the difference

    <script type="text/javascript" src="script.js"></script> is usually HTML (regardless of the doctype used)
    <script type="text/javascript" src="script.js"/> is the XHTML equivalent.

    Unless you have a specific reason for using an XHTML doctype when writiing HTML you should use an HTML doctype. Unless you have a reason for needing to support obsolete tags you should use a strict doctype.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  15. #15
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SilentBobSC View Post
    XHTML does not allow for your tags to be capitalized, the browsers don't care but the validator does.
    Browsers care if you're actually using XHTML (i.e. an XML MIME type rather than text/html). Example:
    Code:
    data:text/xml,<html xmlns='http://www.w3.org/1999/xhtml'><script>alert("Worky")</script><SCRIPT>alert("Not worky")</SCRIPT></html>
    Quote Originally Posted by SilentBobSC View Post
    There are also limitations placed on which tags can use which attributes, the most popular being the EMBED/OBJECT tags used for embedding flash elements.
    HTML has the same limitations.
    Simon Pieters

  16. #16
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML - Hyper Text Mark-up language
    XHTML - Extensible Hyper Text Mark-up language
    We use HTML in designing simple webpages.
    XHTML 1.0 Transitional is an improved version.

    I too am not an experienced person and i knew this much only.

  17. #17
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,243
    Mentioned
    239 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by mithu143 View Post
    HTML - Hyper Text Mark-up language
    XHTML - Extensible Hyper Text Mark-up language
    We use HTML in designing simple webpages.
    XHTML 1.0 Transitional is an improved version.

    I too am not an experienced person and i knew this much only.
    This is not correct, I am afraid.

    HTML HyperText Markup Language
    XML - Extensible Markup Language

    XHTML doesn't stand for anything in particular as far as I know (or at least, the W3C don't say that each letter is a reference to a particular word)

    XHTML 1.0 Transitional is not a improved version of HTML. It is, to make it simple, HTML as XML. But if you don't serve it as an application, it is exactly the same as HTML.

    Transional simply tells the browser that it may be an old document and that may be old tags and presentational tags (such as <center>, <b> or <i>), or maybe old attributes that are obsolete. Using a Strict DTD, these tags and attributes would not be allowed and the document would not validate if they were used.

  18. #18
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by molona View Post
    XHTML doesn't stand for anything in particular as far as I know (or at least, the W3C don't say that each letter is a reference to a particular word)
    Just a quick correction for you molona, XHTML does stand for something (and it is "Extensible Hypertext Markup Language"), it inherited the Extensibility X from XML

  19. #19
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Two handy references:

    Activating Browser Modes with Doctype - Choosing a Doctype

    Web-Sniffer HTTP Request & Response Header Viewer - can be employed to check how any Web Page is being served to various Graphical Browsers (specified via User Agent window).

    James

  20. #20
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,836
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by jamesicus View Post
    Two handy references:

    Activating Browser Modes with Doctype - Choosing a Doctype

    Web-Sniffer HTTP Request & Response Header Viewer - can be employed to check how any Web Page is being served to various Graphical Browsers (specified via User Agent window).

    James
    Theymay be useful references but neither of them has anything whatever to do with this topic since neither of them relate to the difference between HTML and XHTML. The first reference is about the doctype and the second about what HTTP protocol the page is using but neither covers the MIME type which is what determines whether a page is HTML (with MIME type text/html) or XHTML (with MIME type application/xml+xhtml).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  21. #21
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,836
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The way to really tell whether it is HTML or XHTML is to examine the MIME type.

    If the MIME type is "text/html" then it is HTML.
    If the MIME type is "application/xml+xhtml" then it is XHTML.

    An easy way to tell the difference between these is to try to load the page using Internet Explorer 8 or earlier. Those browsers do not understand the XHTML MIME type and so will offer the file for download instead of loading the page into the browser window.

    If you try to access http://www.felgall.com/realxhtml.php with Internet Explorer you will see exactly what happens with IE and XHTML.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Tags for this Thread

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
  •