Forum Moderators: open

Message Too Old, No Replies

Are these declarations required for xhtml pages?

         

ericgeneric

11:47 am on May 30, 2005 (gmt 0)

10+ Year Member



Hi there,

Been a while since I asked for help as I have learnt a lot on my own. I have a question for you now though:

Are these declarations needed for xhtml pages?

<?xml version="1.0" encoding="UTF-8"?> (1)
<contains doctype>
<html xmlns="http://www.w3.org/1999/xhtml"> (2)

Regards,

Richard

encyclo

12:22 pm on May 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<?xml version="1.0" encoding="UTF-8"?>

Using an XML prolog is best avoided: it is not required (but you do still have to declare the charset) and its presence pushes Internet Explorer into quirks mode. You should start with the doctype only.

<html xmlns="http://www.w3.org/1999/xhtml">

It's not vital but it should be used for completeness.

ericgeneric

12:27 pm on May 30, 2005 (gmt 0)

10+ Year Member



Thank you very much for that answer. I have done as you suggested and everything works just fine. Do you happen to know anything about javascript rollovers and the name and id attriubte in the context of xhtml?

Thanks again,

Richard

Robin_reala

5:21 pm on May 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll find that when you come to serve XHTML with the proper media type that things will break (afaicr styling in particular) if you don't include the namespace declaration. The XML prolog is again only required for XML1.0 (which XHTML is based on) if you need to declare a charset, and you can do that in other ways with XHTML.