cs.punk Posted March 6, 2009 Share Posted March 6, 2009 Seriously this story has haunted me! I thought it was just a rename for the new HTML and that i's basically the same with new commands etc! And all the e-books I read all use the format I use (I THINK)... XHTML has <p>hello<p> commands while HTML has <p>hello</p> ? Somebody please tell me the difference lol... And if I should worry? Oh and can anyone tell me a good book for CSS? All I thought it was is for saving font, color, size in one shortcut but it seems to be much more Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/ Share on other sites More sharing options...
Mchl Posted March 6, 2009 Share Posted March 6, 2009 http://en.wikipedia.org/wiki/XHTML#Relationship_to_HTML Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-777980 Share on other sites More sharing options...
ejaboneta Posted March 6, 2009 Share Posted March 6, 2009 I understand the differences between how to write html and xhtml but what are the benefits to each? Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-778573 Share on other sites More sharing options...
haku Posted March 8, 2009 Share Posted March 8, 2009 There really isn't any. It's personal choice. The idea behind XHTML was that it would be parsed using an XML mimetype (don't worry about what that is if you don't know), but IE doesn't support this, and since IE is the most used browser out there, it basically made XHTML pointless. Everyone just parses XHTML as HTML, and so they are eventually the same. If you want to make a wise choice, parse using a strict version of either of them, and not the transitional version. Then make sure that your code is valid. This is much more important and will have more benefits for your code than the choice between HTML and XHTML. Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-779536 Share on other sites More sharing options...
jackpf Posted March 8, 2009 Share Posted March 8, 2009 I think xhtml sounds cooler, so I stick with that Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-779674 Share on other sites More sharing options...
Daniel0 Posted March 8, 2009 Share Posted March 8, 2009 http://www.phpfreaks.com/forums/index.php/topic,241905.msg1128777.html#msg1128777 I think xhtml sounds cooler, so I stick with that What separates pros from amateurs is that the former group knows why and when to use a specific tool. Just saying. Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-779926 Share on other sites More sharing options...
jackpf Posted March 8, 2009 Share Posted March 8, 2009 No need to get personal; however, I'm fully aware that I'm not a pro. I'm a sixteen year old pubescent noob to be brutally honest. But I try Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-779934 Share on other sites More sharing options...
Daniel0 Posted March 8, 2009 Share Posted March 8, 2009 Don't take it as offense. I'm merely saying that one should have a broad knowledge of their entire tool set such that they can better make an educated estimation as to what would be better to choose in a given scenario. Part of what makes you a good programmer is that you are able to pick the right tool for the right job. If something for some reason is better than the latest cutting edge whiz-bang technology or whatever you perceive to be "cooler", then use that instead. Considering that you're 16 years old, it wouldn't take long before to you an increasing extent will be required to argue for your opinions during your education. Just because something is newer doesn't necessarily make it better. That fallacy is called argumentum ad novitatem. XHTML does have some application, but for a regular website I do not think it's the right tool to use. Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-779943 Share on other sites More sharing options...
Mchl Posted March 8, 2009 Share Posted March 8, 2009 That fallacy is called argumentum ad novitatem. Oooh... a new one to my collection... Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-779949 Share on other sites More sharing options...
jackpf Posted March 8, 2009 Share Posted March 8, 2009 I see your point...but from what you've taught me, they're both incredibly similiar. So since XHTML is newer, and appears not to differ from HTML, why not use it? Tbh, I could actually just change my doctype and remove my xml declaration and it'd be html. It validates against all markups. So in my eyes, it makes little difference... Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-779953 Share on other sites More sharing options...
svivian Posted March 8, 2009 Share Posted March 8, 2009 In a nutshell, XHTML is the same as HTML but with a few differences that make it more "robust": All tag names must be lowercase - i.e. <html> instead of <HTML>) All elements must have corresponding closing tags - i.e. <p>paragraph</p> instead of <p>paragraph Elements without closing tags should use /> - i.e. <br /> and <img src="..." /> instead of <br> and <img src="..."> All attributes must be in quotes - i.e. <span class="test">something</span> instead of <span class=test>something</span> All attributes that are used must have values - i.e. <option selected="selected"> instead of <option selected> Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-779983 Share on other sites More sharing options...
Mchl Posted March 8, 2009 Share Posted March 8, 2009 This still doesn't answer the question: 'why use XHTML over HTML?' Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-779985 Share on other sites More sharing options...
haku Posted March 9, 2009 Share Posted March 9, 2009 I think I answered that in my post - it's just personal preference. I really don't think that there is any reason to use XHTML over HTML, and I also don't think that there is any reason to use HTML over XHTML. Although if someone has one, I'm interested in hearing it. Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-780079 Share on other sites More sharing options...
jackpf Posted March 9, 2009 Share Posted March 9, 2009 Well...it does look a lot neater when you've closed all tags in the right order..idk, i just prefer it... Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-780162 Share on other sites More sharing options...
Daniel0 Posted March 9, 2009 Share Posted March 9, 2009 There are certainly a lot of differences between XHTML and HTML. First of all, HTML is based on SGML whereas XHTML is based on XML. The X is short or extensible, i.e. Extensible Hypertext Markup Language. Unless XHTML is served as application/xhtml+xml then it won't (and should not) be treated as XML by the UAs. If it's served as text/html then it will be treated as HTML. Some people think that it is the DTD that determines whether it is XHTML or HTML, but that is wrong. The DTD is merely a document containing grammar constraints. Of course if you serve XHTML as text/html then you miss out on the "extensible" part of XHTML, but if you serve it as application/xhtml+xml then you won't have any IE users for sure. XHTML, when served as such, can be extended by any other XML based technology using XML namespaces. An example of that could be MathML. Inserting the following in an XHTML document: <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> <mi>y</mi> <mo>=</mo> <mfrac> <mn>1</mn> <msqrt> <mrow> <msup> <mi>x</mi> <mn>2</mn> </msup> <mo>+</mo> <mn>1</mn> </mrow> </msqrt> </mfrac> </mrow> </math> Would produce something like [tex]y=\frac{1}{\sqrt{x^2}+1}[/tex] when served as application/xhtml+xml, but if you serve it as text/html then it'll look like y = 1 x 2 + 1 because all those elements are invalid in HTML and as such ignored. Another example is SVG for embedding vector graphics. Here is another difference: HTML-style <style type="text/css"> <!-- h1 { font-size: 1em; } </style> XHTML-style <style type="text/css"> <![CDATA[ h1 { font-size: 1em; } ]]> </code> If the former snippet is (wrongly) served as application/xhtml+xml then it won't work, and similarly, if the latter snippet is (wrongly) served as text/html then it will not work either. Furthermore, the default character set for HTML is latin-1 (ISO-8859-1), but the default character set for XHTML is UTF-8. Indeed the only character sets an XML parser is required to support is UTF-8 and UTF-16. This can result in an odd output littered with strange symbols if you do it wrongly. The thing is, you cannot use XHTML for Internet Explorer. It simply does not support it (the user will be prompted to download the page because IE doesn't know what to do with it). Some people have proposed to use content negotiation to serve different content to different UAs, but the problem is that a lot of the UAs lie about what they do accept. You will for instance find */* in IE's Accept header, but this is quite obviously untrue. That would constitute supporting literally every thinkable MIME type, including those which have not yet been invented. This would mean that it claims to support application/xhtml+xml as well, but it is fairly easy to verify that it does in fact not. Moreover, the working draft of XHTML 2 is not backwards compatible with XHTML 1.x or HTML 4.x. HTML 5 will be backwards compatible. It doesn't look like XHTML 2 is going very strong whereas HTML 5 is well on its way. There are a number of subtle syntactical differences between XHTML and HTML. Most notably the XML self closing tag. HTML does not support this. If you have <img src="foo.jpg" /> in HTML (or indeed XHTML served as text/html which then de jure is HTML) then it will technically speaking be invalid. The / is regarded as an invalid attribute and discarded. So a lot of those websites featuring "Valid XHTML 1.0" should say "Invalid HTML 4.01". All of those are just some of the differences between XHTML and XML. In 2007, Håkon Wium Lie (CTO of Opera and W3C member) said "So, I don't think XHTML is a realistic option for the masses. HTML5 is it." (source). Microsoft has also expressed that XHTML will not be supported in IE in the near future. Numerous other notable people in the industry have also stated that HTML is the way to go. Well...it does look a lot neater when you've closed all tags in the right order..idk, i just prefer it... There is no reason why you cannot do that in HTML as well. By the way, I'm going to sticky this topic. Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-780240 Share on other sites More sharing options...
WolfRage Posted March 13, 2009 Share Posted March 13, 2009 After reading both replies (Articles) I have been thoroughly educated. In the beginning when I was learning web development I was digging deep into understanding DTD and the differences between HTML and XHTML, but I have obviously overlooked it since due to my IDE defaulting to XHTML. I will now have to go back and apply what I have learned about HTML and stop using XHTML, because as stated I really am not being compliant with XHTML any ways. Plus it is easy enough to change the settings on my IDE. Thank you for the enlightening responses Daniel0. Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-784000 Share on other sites More sharing options...
jackpf Posted March 13, 2009 Share Posted March 13, 2009 Yeah...good advice. You seem like a knowledgeable chap, Daniel0. Btw, I tried serving my entire sit as application/xhtml+xml It actually worked, minus a few bugs which I've now resolved. Yeah...javascript didn't work too well in firefox though, but fine in opera. IE completely bodged it lol. Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-784016 Share on other sites More sharing options...
dbrimlow Posted March 15, 2009 Share Posted March 15, 2009 It is a matter of starting properly and not getting into bad habits early. XHTML is basically a stricter version of HTML 4.01 (only tags must be lower case and all the end tags are not optional and self-closing tags are requires for single tags like br, img, meta) Since you are young, you may as well learn the proper way to markup HTML code. Using HTML vs XHTML is Less important than using a "strict" dtd instead of "transitional". You can get a head start on coding the right way instead of having to break yourself of bad habits later (like most of us who have been doing this since the '90s). I personally use and validate to html 4.01 strict, but I use the rules of xhtml. By that I mean I code in all lower-case, and if you took my html 4.01 page and simply added the closing slash to self-closing tags it would be xhtml 1 strict. The funny thing is that job recruiters have absolutely no clue, either, and think that XHTML is some cutting edge proof of skill and is what professionals use. Actually the opposite is true. Amateurs use xhtml much more than pros - only they mess it all up and don't follow the rules. I have kept one or two of my sites in xhtml simply for clueless job recruiters or potential employers. Learn VALID strict markup - html 4.01 or xhtml1. People who actually know better will be most impressed if you use html 4.01, though, instead of xhtml. Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-785311 Share on other sites More sharing options...
Daniel0 Posted March 15, 2009 Share Posted March 15, 2009 XHTML is basically a stricter version of HTML 4.01 (only tags must be lower case and all the end tags are not optional and self-closing tags are requires for single tags like br, img, meta) It's not stricter. Although they look similar they're not based on the same language. HTML uses another syntax so it's rubbish saying that XHTML is stricter for those reasons. [...] if you took my html 4.01 page and simply added the closing slash to self-closing tags it would be xhtml 1 strict. No it would not. Read back in this topic. The funny thing is that job recruiters have absolutely no clue, either, and think that XHTML is some cutting edge proof of skill and is what professionals use. Actually the opposite is true. Amateurs use xhtml much more than pros - only they mess it all up and don't follow the rules. Agreed. Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-785327 Share on other sites More sharing options...
jackpf Posted March 15, 2009 Share Posted March 15, 2009 Yeah...I agree with most of that. But since xhtml 1.1 basic is actually stricter than xhtml 1.0 strict (there isn't a 1.1 strict, it's just 1.1 basic) and my site is pretty much valid, I reckon that's ok tbh. Plus, the fact that it actually worked almost flawlessly (void the javascript for some reason) when I changed my content type to application/xhtml+xml. Considering my code is actually valid xml, I don't see any problem with it. I don't think it really makes a difference whether my site is xml or html, as long as it's valid either way. Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-785385 Share on other sites More sharing options...
Daniel0 Posted March 15, 2009 Share Posted March 15, 2009 Bar the fact that IE, having a 67% market share (source), doesn't support it. I'd also like you to back up your argument that XHTML 1.1 is stricter than 1.0 Strict. Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-785391 Share on other sites More sharing options...
jackpf Posted March 15, 2009 Share Posted March 15, 2009 Yeah, I changed it back anyways. And yeah, my site's all in xhtml now, so it's not like I can change it to html without a lot of effort And well, when I had xhtml 1.0 strict as my doctype, my forum validated fine, when I upgraded to 1.1 it was fine, but when I then went to 1.1 basic, it said cellspacing wasn't a valid attribute. So I assumed that 1.1 basic is stricter. I could be wrong though, idk. Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-785397 Share on other sites More sharing options...
Mchl Posted March 15, 2009 Share Posted March 15, 2009 Maybe it just has different specification? What is valid in one dialect, might not be in another. Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-785399 Share on other sites More sharing options...
jackpf Posted March 15, 2009 Share Posted March 15, 2009 Yeah. I just assumed it was stricter because I've noticed stuff that isn't valid in 1.1 that is valid in 1.0, but not the other way around. Besides, why would they start allowing stuff in a new dtd that they condemned in an old one? Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-785401 Share on other sites More sharing options...
dpacmittal Posted March 20, 2009 Share Posted March 20, 2009 Thanks for all the knowledgable posts. I only knew that XHTML was a strict version of HTML. The fact that IE doesn't support xhtml and IE having major market share, is alone enough for a reason to not use it. Isn't it? I don't understand one thing though. If XHTML has no added benefits over HTML and if IE doesn't support it, why are people still using it? Quote Link to comment https://forums.phpfreaks.com/topic/148204-html-xhtml-any-difference/#findComment-789326 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.