PDA

View Full Version : How can I get IE to see the tag?


chreo
08-07-2006, 02:25 PM
IE can't read this with <?xml version="1.0" encoding="utf-8"?> at the top.
<!--[if IE]> <link rel="stylesheet" href="css/text1_IE.css" type="text/css" /> <![endif]-->
</head>If I take away the xml-tag, it works fine, and the document validates the same. This is probably a very silly question, but it bothers me, and I would really like to know!:)

Question 2: Can xml-browsers still read the page without that line?

Question 3: I have always had charset=ISO-8859-1
Is charset=utf-8 better or necessary?

Background:
I have a document that validates as XHTML 1.0 Strict, and functions in both Fx and IE, but I read somewhere that since most people use IE, and IE does not support XHTML, we might as well stick to HTML. I had not experienced any problems, so I checked for doctypes on W3C and found that I had not put the complete doctype in my document. I switched mine for theirs, and THEN the page worked so-so in IE. Here is the code:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>Links page</title>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link href="css/text1.css" rel="stylesheet" type="text/css" />

<!--[if IE]> <link rel="stylesheet" href="css/text1_IE.css" type="text/css" /> <![endif]-->
</head>

Kravvitz
08-27-2006, 05:34 AM
XML documents SHOULD begin with an XML declaration which specifies the version of XML being used. (http://www.w3.org/TR/xml/#sec-prolog-dtd)

That's one of the reasons why I prefer using HTML 4.01 Strict. I can cause IE6 to render the page in standards mode without anyone being able to say I'm not following best practices.

A browser would only use an XML parser to parse a document if it was served with an XML mime-type, e.g. application/xhtml+xml and application/xml.

jkd
08-27-2006, 06:05 AM
XML documents SHOULD begin with an XML declaration which specifies the version of XML being used. (http://www.w3.org/TR/xml/#sec-prolog-dtd)

Should doesn't mean must. It is perfectly acceptable to serve XML documents without the XML prolog, as long as the server properly sends character-encoding information to the client.

Kravvitz
08-27-2006, 06:11 AM
I know.

XML1.1 says you must include it though. (http://www.w3.org/TR/xml11/#sec-prolog-dtd)

In IE7 they fixed the IE6 bug that causes the doctype to be ignored when the XML Declaration is present.