June 25, 201016 yr hello! i would like to ask several question on the topic xml declariation is for tell the browser which version of xml the doc is, right? it should be on the first line.. but some says it's not a good idea to put there because older browser get in quirks mode. so ignore it or what? what an xml doc loose if no declaration in it? when i use dreamweaver to setup a site it only includes .. oh this one is solved the last 2: when i watch sites code via my browser, i see a lot <meta ... > line include and i only uses title, keywords, and description... what is meta good for further? what's the main difference beetwen xhtml 1 and xhtml1.1 ( i see there are no different doctypes for 1.1 ) thanks!!!!! have a nice day!
June 25, 201016 yr Hi tomika, Declaring document type and character encoding is not too complex, but is something that many people don't take the time to read up about. Fortunately many browsers are forgiving and still load a page if these are wrong even if it means the page doesn't validate. The 'xml declaration' you are referring to I assume is the character encoding declaration for XHTML documents. For XHTML documents the character encoding declaration is different to HTML and you are right it is an xml statement which should appear on the first line such as this: <?xml version="1.0" encoding="ISO-8859-1"?> The 'encoding' section refers to a particular region and tells the browser what characters to expect in the page, ISO-8859-1 is western europe. Obviously, if you used ISO 8859-7 which is greek, you can imagine the browser would be expecting very different characters to our alphabet. You will also often see utf-8 which is a unicode declaration and can represent any character in the unicode standard. It's worth noting that character encoding appears as line 1 in an xml statement for XHTML, but appears as a meta tag for HTML (and should not appear as a meta tag for XHTML). If you don't declare this, I'm not sure what would happen, but my guess would be that the browser would default to assuming utf-8. The different between XHTML 1.0 and XHTML 1.1 is just that is a newer standard, just like when HTML 5 *finally* arrives, that will be the next standard. There are lots of articles on specific differences between them in terms of available tags and so on. As for DOCTYPE: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> This tells the browser believe it or not, what type of document it is. There are obviously differences between XHTML and HTML, so the browser needs to know which it is. For instance <br> is not a valid XHTML tag, but <br /> is, so the content of the document will be different according to the DOCTYPE. Finally, meta tags are for declaring various information about the website, who wrote it, keywords for search engines, copyright information and so on. Have a look at this useful page for specific details on each meta tag.
June 25, 201016 yr Don't use XHTML 1.1. It is supposed to be used with <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8"/> which will never work with IE6 and older browsers. It's for specialist XML based languages like SVG and MathML and inappropriate for normal websites. Use HTML 4.01 or XHTML 1.0 both with <meta http-equiv="content-type" content="text/html; charset=utf-8"/> (closing tag just > not /> for HTML). which will process as HTML. With XHTML 1.0 you will be coding the markup as XHTML but a few lines later the content="text/html; tells the browser to process as HTML. HTML 4.01 will be superseded by HTML 5 in a few years and XHTML2 will be reserved fo special XML websites when using content="application/xhtml+xml; although there will be a compromise X/HTML5 (note the / between X and H) when used with content="text/html; It's all a bit confusing at the moment as HTML and XHTML are really being split off for different types of website in the future. Item 1.6 HTML vs XHTML in the W3C HTML5 http://dev.w3.org/html5/spec/Overview.html page says The first such concrete syntax is the HTML syntax. This is the format recommended for most authors. It will be backwards compatible. Most people don't use <?xml version="1.0" encoding="ISO-8859-1"?> when using XHTML 1.0 Look at the source code for this forum. In fact it can upset some browsers.
June 25, 201016 yr Yep, W3C confirms <?xml version="1.0" encoding="ISO-8859-1"?> is for XML parsers only, so XHTML should still use the meta tag characters encoding declaration (it should sit above the title tag), so ignore what I said above Thanks for the more detailed info on the XHTML 1.1 vs 1.0!
Create an account or sign in to comment