This question already has answers here:
Is HTML5 backwards compatible with XHTML?
(3 answers)
Closed 9 years ago.
Currently I have my website coded in XHTML strict. Can it be converted to HTML5 only by changing doctypes? Or are there other changes I need to make?
A really useful tool for checking if your site is html5 compatible is the W3C Markup Validator. If you update the doctype to <!DOCTYPE html> and then run the html through the validator, it will show you all instances of where your html is not currently compatible with html5.
This will most likely include changing some self closing tags, some properties may have changed and if you truly want to be html5 up to date (rather than just compatible) you should consider using the <header>, <nav>, <section>, <article> tags, instead of just normal divs.
Updating may also make your page look different on non compatible browsers, in this case I recommend using html5shiv so that older versions of IE support the new tags that you're using.
You also have to change many tag elements if you want "true" HTML5 such as menu, section, footer...
Also it may require some changes in CSS as in HTML5 all elements have div's properties.
And you'll need to use some scripts to support HTML5 in old IEs.
XHTML works fine in HTML5 and is nicknamed 'XHTML5' but, if you're not serving it as application/xhtml+xml, then you're not getting any of those advantages. You shouldn't be using XHTML if you're not serving as such anyway. You're also not gaining anything by just changing the doctype unless you're going to rewrite the current page and add some new elements, use APIs, and all that.
If you are only going to do a step-by-step conversion over time, you can swap doctypes and you probably won't notice any difference. Run it through the validator to check for errors. Fix your errors before moving on.
Related
I'm working on a new website, and I want to support as many old browsers and operating systems as possible, as easily as possible. From what I've been reading, I know I'm better off avoiding quirks mode, so I need to decide on the best doctype. And everyone seems to be recommending the HTML5 version:
<!DOCTYPE html>
But according to this website, that also recommends the HTML5 version:
https://hsivonen.fi/doctype/, that doctype will trigger quirks mode in Netscape 6, and maybe in Konqueror 3.2. But this one:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
won't trigger quirks mode in any browser listed on that website.
So my question is, is there any reason why I shouldn't use the 2nd doctype? I know those are really old browsers I'm concerned about, but I've seen recent statistics saying Netscape 6 is still in use, at least in Russia. And where I live, I still see a lot of people using Windows XP. So while I don't want to spend a lot of time supporting obsolete browsers, I'm wondering if there are any disadvantages to using the 2nd one, other than it's longer and looks complicated.
edit: All the answers and comments posted so far, have been really helpful. Now I'm starting to see that it's a tradeoff between:
1) being semantically correct, and
2) putting more of the very old browsers into standards mode, instead of quirks mode
In most cases #1 is probably more important, since not many people use those really old browsers. And if they do, they're probably used to things looking a little off. But if you're more concerned about things looking better in really old browsers, then #2 could be a better choice.
Anyway, I'll wait a while to see if anyone adds any more answers or comments. Thanks!
edit 2: All 3 answers were helpful. And 2 of them helped me understand specifically what I needed, so I selected one of those. But I would have selected both, if I could have.
The only reason I can think of is that if you want or need to use HTML 5 in the future you'll be able to with more ease already doing everything in HTML 5.
And browsers should have no problem dealing with the fact that it's strict 4.01 and will display it just as if it didn't have the doctype anyways.
Basically from a "what the page looks like" point of view your strict 4.01 will look the same in a html 5 doctype as it will in a strict.
Having said that, it does depend on your HTML there are certain times that you'll need to do it but chances are it shouldn't matter
Really good link for further info on doctype declarations:
http://www.htmlgoodies.com/html5/markup/the-doctype-tag-and-its-effect-on-page-rendering.html#fbid=JCm-bKCUNc6
There are several reasons:
Old browsers(those that doesnt support html5) wont be forever, one day the will be gone but those browsers that can support html5 will take long time in order to be a "old browser". So try to take advantages of all those new html5 feactures.
HTML5 has some new tags that are better for S.E.O
HTML5 Introduced new video codecs that will improve the audio and video experience.
HTML5 introduced a really drag and drop feature!
So what I suggest you is to use html5 and try do your best to make "old browsers" run your html5 website.
I would just use the , but not use any HTML 5 specific features, I think that would work nicely. Older browsers try to render the page as good as they can. In any case, if you DO want to use HTML 5 features, you can always see if they are available in your javascript code or use a framework such as modernizr.
According to me main reason is that :
<!DOCTYPE html>
Html5 : Supports header, footer and section tag. And this tags are easily readable to google for "Search Engine Optimization". So, google takes it as important content on our page.
And for "4.01 strict" :
These header, footer and section tags are not supported.
Regarding a site I built a few years back, I've been asked "Does the site support HTML5?"
The site was built a few years back using standard HTML.
What is the correct response to a question like this? I thought it was browsers which either support HTML5 or not as they render the script?
This is not really an appropriate question.
But your site will continue to work in browsers that support HTML4 and the doctype you are using. This support is likely to continue for quite some time.
You can easily start to move your site towards HTML5 by adding the HTML5 doctype:
<!DOCTYPE html>
The HTML5 doctype is backwards compatible.
You can read some more here: How to write backwards compatible HTML5?
If your site is valid "HTML4" - there are many flavors - your site will be future proof, even if it is not written in HTML5.
You can test compatibility with the W3C Markup Validation Service
Short answer: Yes - IMO this question is more about will browsers continue to support the HTML4?
However, HTML5 does begin to deprecate some elements / attributes present in HTML 4 and I can imagine a scenario in the future where browsers may begin to also.
Document type support varies betweeen browsers.
You should check the differences between HTML5 specs and your site doctype specs to see if the two are compatible, to mantain it standards compilant.
Anyway the problem is the contrary, a website using new HTML5 features may not be compatible with older browsers not supporting them.
I'm beginning a very large project in the coming weeks and am trying to decide if I should take the leap into HTML5 land or stick with my time trusted XHTML 1 strict.
The site will be huge. Thousands of pages, video, custom CMS system, lots of social media integration, etc. I'm trying to justify using the new technology, but am unsure (as I've never done a huge site in 5) if everything will go according to plan on older browsers.
I can sit there and talk all day long about the new technology that html5 brings, but when you're sitting in a board room full of execs and the site doesn't work on their IE6 machines...not good.
Let me know what you guys would do. - Thanks
Choosing to use the HTML5 vocabulary is an orthogonal issue to whether to use XHTML syntax. If you want to use HTML5 elements and still work with XML production tools, you can always use XHTML5.
HTML5 is not yet finished so to some extent you will be labelling your documents with a doctype of unknown quantity, and validating it isn't as easy. But if your project is going to be using elements like <video> at any point, using an HTML5 doctype makes sense. (Though hopefully if you are using a custom CMS it should be relatively straightforward to adjust the doctype it spits out in the future anyway?)
None of this is relevant to IE6 compatibility as such. IE6-8 will render the page the same with any of the Standards Mode doctypes, and won't ever render <video> regardless of whether you're using an HTML5 doctype. You will certainly need fallback for any HTML5 extensions you use, such as Flash for <video>. The extended HTML5 semantic elements like <section> or <article>, you don't really get anything for using anyway; avoid them for now.
While HTML5 is not fully complete, much of it can be used today. It was designed with compatibility in mind, so a number of the new elements will work in older browsers, even if they don't specifically support HTML5.
You can start using the new doctype - any browser will recognize it as valid. From there, you can do your layouts using the new semantic structural elements - section, aside, header, footer, etc. You'll need to style these a bit to get them appearing correctly, and there is a shiv script for IE compatibility. It takes a little work, but they provide much more semantic value than the generic div.
audio and video elements have fallback capabilities for older browsers, so by all means use them.
Various new form elements and attributes are not widely supported yet, so you probably won't get much value from them right now. Though I quite look forward to using them, as they will reduce need for client-side scripting a fair bit.
IE6 is the obvious element in the room, but with the right setup, and use of fallbacks in HTML5, there should be no serious issues from using HTML5. CSS is another matter, of course. But IE9 is looking rather good, and will help to raise the bar for standards support.
HTML5 is a better choice here. It offers improvements as well as compatibility; and will render in all browsers. Modern features such as <video> can be sniffed for and replaced by FLV players or other alternative in non-compatible browsers.
XHTML has been redundant since its creation, and XHTML 1.0 (when sent with the correct mime type) doesn't work at all in IE6. Using HTML5, it will both render and be functional, assuming you handle the lack of support of modern features properly.
Are there any pros to use the HTML 5 doctype <!DOCTYPE html>, even if I am not using any new HTML 5 tags? Are there any benefits to replacing the XHTML doctype with the HTML 5 doctype, even if I am not using any new HTML 5 tags?
Can the HTML 5 doctype create problems in terms of functionality if I am using anything XML related with my site, or using HTML 5 for web development with any A-Grade browser? Is it supported in all desktop and mobile browsers?
Or, for right now, is it good to stick with the XHTML Doctype until 2015?
You may be interested to check out John Resig's blog post on this topic (the founder of jQuery):
What's nice about this new DOCTYPE,
especially, is that all current
browsers (IE, FF, Opera, Safari) will
look at it and switch the content into
standards mode - even though they
don't implement HTML5. This means that
you could start writing your web pages
using HTML5 today and have them last
for a very, very, long time.
You may also want to check out the following Stack Overflow post (August 2008):
Any reason not to start using the HTML 5 doctype?
Is there any pros to use HTML 5 doctype even if i'm not using any new HTML 5 tag?
Slightly less typing.
That's about it.
I wouldn't use the HTML5 doctype yet. With this doctype you're stating that your document conforms to a specification that is still a moving target. IMO: wait until the spec is finished and the validation process tied down.
Absolutely. It works in every browser except IE6. There's shorter script declarations. And it's easy to remember.
It will surely break at least one old browser out there, so I recommend not using HTML 5 unless your page is actually HTML 5.
Also, XHTML and HTML 5 are not strictly compatible.
I have recently been learning about doctypes, and was I wondering what the differences between <!DOCTYPE html> and some of the others were.
I know <!DOCTYPE html> is the HTML5 doctype and it is experimental, but I was wondering what would happen if I used it instead of the other doctypes?
Thanks in advance!!!!
Basically what will happen is that you'll get your page rendered in a "standards mode".
The only reason why you probably shouldn't use the new DOCTYPE is if you want to use XHTML 1.0 markup and conform to XHTML 1.0.
The downside to using HTML5 now is that the spec can change. This makes it important for you to keep up with the spec as it actively changes.
With that being said, I've already started using the new syntax in my pages. Also it guarantees that your page will last for a very, very, long time.
So go ahead, use it (and learn to love how simple it is).
The HTML5 doctype isn’t experimental. Ian Hickson tested a bunch of browsers, and found that <!DOCTYPE html> worked the same in them as the HTML 4 and XHTML 1 doctypes (i.e. it triggered standards mode).
However, if you use it, then validators will (by default) validate your page as if it’s HTML5, which may not be what you want if you’re actually writing HTML 4. (For example, some elements are getting dropped in HTML5. Using them would show up as an error if you validated your page as HTML5.)
Lucas nailed the most important aspect. Let me explain this in a slightly different way:
In the browser the doctype serves exactly one purpose, to set the rendering mode: Quirks, almost standards and full standards mode. This used to be simple until MSIE 8 introduced a second switch, "compatibility mode" = MSIE7 bugs and limitations are preserved on purpose.
An HTML5 doctype will (usually) override that setting, and is thus somewhat more powerful than XHTML 1.x or HTML 4.01 doctypes. (MSIE may override it sometimes, though.)
The definitive guide to doctype switching and layout mode is at: http://hsivonen.iki.fi/doctype/
The second thing that will happen is that you get your pages validated according to the HTML5 rules. Some elements and attributes that were allowed in HTML 4 are gone and a bunch of new ones have come.
Edit: Removing example. Mixing what used to be known as inline and block elements is now OK. (In the original proposal it was not.)
The semantics and syntax for HTML5 is mostly like the one in HTML 4, so most well written HTML 4 sites will continue to validate. The main difference is that you mat start to use the new stuff and still be valid.
There's nothing illegal about
<div>
<p>foo</p>
<span>bar</span>
</div>
(The terms 'block level' and 'inline' elements are obsolete in HTML5.)