Doctype declaration nor recognized in IE -> Error?
I have a XML Page which launchs weel in Firefox, without any problem. But it definitely does not want to launch in IE 7. And I really don't know why. Here is the doctype declaration :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
and here the arugments in the html tag :
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
and h开发者_StackOverflow社区ere is the error I get :
The XML page cannot be displayed Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
The download of the specified resource has failed. Error processing resource 'http://www.w3.org/TR/html4/strict.dtd'.
or
'http://www.w3.org/TR/html4/loose.dtd'.
depending on the declaration I choose in this list : http://www.w3schools.com/tags/tag_DOCTYPE.asp
What should I change to enable IE to launch it ?
Thank you very much.
Have you tried a transitional doctype?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Failing that, run your page though the W3C validator: http://validator.w3.org/. That will flag up any issues in your code that are working against the doctype.
It is not possible to use real XHTML in IE8, IE7 and earlier. You should send to all browsers MIME text/html
. You may also use HTML5 doctype too: <!DOCTYPE html>
. It is shorter and works.
It sounds like you have a validation error in your xhtml code.
Without seeing the whole document, I can't tell you what that validation error is, but you can find out by pasting the code into the W3C's HTML Validator page. This will give you a detailed run down of any errors in your page.
Because you're using the strict xhtml doctype, the browser will enforce strict compliance of the page to the xhtml spec. This means that it will fail if you're using an invalid tag or attribute, as well as more obvious problems of broken XML.
The strict xhtml spec actually dropped quite a number of tags which were allowed in previous versions of html. If you're using any of these tags, then you'll have errors. If this is your problem, then it can be resolved by switching to the transitional xhtml doctype instead.
In fact, you might even consider using a non xhtml doctype entirely -- your xhtml code will be perfectly valid if you use the HTML5 doctype, and this will also give you more freedom to use additional browser features (although obviously this will be of limited use in IE7!).
But all these questions will be answered when you run your code through the validator, so that's the first thing I'd suggest you do.
Hope that helps.
精彩评论