Page 1 of 1

First line of a XHTML 1.0 Strict document

Posted: Thu Aug 02, 2007 5:04 pm
by Jeroen Oosterlaar
Hi,

I usually define my HTML documents as XHTML 1.0 Strict. However, recently, for a project, I needed to style content images as having a padding of five pixels with a white background and a black border of 1 pixel. This worked fine in Firefox, but Internet Explorer did not show the padding. After some searching, I found out, that I had to put the doctype on the very first line of the document and it worked! However, now the W3 markup validator concludes that the document is invalid, because the XML header could not be found on the first row.

So, the first set up was (IE fails to display the padding surrounding the image and the document is valid):

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
And the current set up is (IE displays the padding, but the document is invalid according to the W3 markup validator):

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?xml version="1.0" encoding="iso-8859-1"?>
How do I solve this? I read somewhere that the XML header is optional, so I could leave out that line, but is that a good practice?

Thanks in advance and kind regards,

Jeroen

Posted: Thu Aug 02, 2007 5:08 pm
by vigge89
Yes, leave the xml line out in my opinion. It's optional and only creates problems.

Posted: Thu Aug 02, 2007 5:13 pm
by Jeroen Oosterlaar
vigge89 wrote:Yes, leave the xml line out in my opinion. It's optional and only creates problems.
Okay, thanks a lot!

It really is frustrating how each browser has its own interpretation of document sources. How more efficient would webdevelopment be, if you could just develop the frond end using only one browser and be absolutely sure that it will be rendered the same way in all other browsers.

Posted: Thu Aug 02, 2007 7:02 pm
by superdezign
Jeroen Oosterlaar wrote:t really is frustrating how each browser has its own interpretation of document sources. How more efficient would webdevelopment be, if you could just develop the frond end using only one browser and be absolutely sure that it will be rendered the same way in all other browsers.
That's the epitome of wishful thinking in web development.

Re: First line of a XHTML 1.0 Strict document

Posted: Fri Aug 03, 2007 10:27 am
by The Phoenix
Jeroen Oosterlaar wrote: How do I solve this? I read somewhere that the XML header is optional, so I could leave out that line, but is that a good practice?
That line is called the xml prolog. It is recommended, but not required.

The prolog causes problems in a number of browsers:

http://www.webstandards.org/learn/artic ... _problems/

But notably, the biggest problem was in IE. I think it was fixed in IE7, but I'm not certain.

So, to answer your question, skip the prolog for now.