July 4, 201115 yr I'm a little confused as to what I should be adding as the Doctype declaration for my website? At the moment I have only the below declaration at the top of each html file: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ....followed by by <html> <head> <title>Page Title</title> <head> <body> Etc... Should I be adding anything else?
July 4, 201115 yr No, that's good for a standard XHTML document. You could go a little further and include a bit more meta data though: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <body> Personally, I'd recommend moving over to HTML5 instead though.
July 4, 201115 yr No, that's good for a standard XHTML document. You could go a little further and include a bit more meta data though: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <body> Personally, I'd recommend moving over to HTML5 instead though. Not could, should - XHTML must always have an XML namespace.
July 4, 201115 yr Author No, that's good for a standard XHTML document. You could go a little further and include a bit more meta data though: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <body> Ok thanks! After posting I looked at a few sites soure code and added this: <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> I've changed the part in bold to charset=utf-8. Out of curiosity, whats the difference? +1 for your help. Personally, I'd recommend moving over to HTML5 instead though. Will definitely be looking into it, once i figure out everything else
July 4, 201115 yr Author Not could, should - XHTML must always have an XML namespace. thank you, added. +1
July 4, 201115 yr Ok thanks! After posting I looked at a few sites soure code and added this: <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> I've changed the part in bold to charset=utf-8. Out of curiosity, whats the difference? ISO-8859-1 is the charset for Latin Alphabet Part 1, which generally means all the characters you can see on your keyboard if you look down. It's designed for websites that display languages you can type on a "Western" keyboard (such as English, French, German, etc...). There are different versions of it for the various languages with different characters such as ISO-8859-6 for Arabic or ISO-8859-7 for Greek. UTF-8 is a more modern character encoding. It's designed to be a universal character set that covers all languages and character types, replacing the need for numerous ISO-8859 types.
July 4, 201115 yr Author I had to change one of my webpage doc type declarations which had a google map embedded to: <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> Without this change I got an error reading the document from an HTML validator. Can you have several meta data tags? eg: <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> More? If so, do they need to be in any particular order?
July 4, 201115 yr I had to change one of my webpage doc type declarations which had a google map embedded to: <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> Without this change I got an error reading the document from an HTML validator. Can you have several meta data tags? eg: <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> More? If so, do they need to be in any particular order? Nope, you should only be using one meta charset. ISO-8859-1 is still okay to use for your site. UTF-8 is arguably better but there's no rule saying you have to use it. It's your choice. Bit odd that a Google Map is kicking out validation errors like that. I assume there must be some funky characters in the URL for it that UTF-8 doesn't recognise.
July 5, 201115 yr I think charset=iso-8859-1 is now out of date. I use utf-8 now. However, as you found out, the validator http://validator.w3.org/ does raise errors with utf-8 if it sees certain characters like £ or = or & or some others. If this is the case, use the character codes from here:- http://www.tedmontgomery.com/tutorial/HTMLchrc.html and then it will validate.
Create an account or sign in to comment