什麼是html xmlns=”http://www.w3.org/1999/xhtml & DOCTYPE v.s. Quirks Mode?
首先先介紹“<html xmlns=”http://www.w3.org/1999/xhtml“>”的用途,
What does “<html xmlns=”http://www.w3.org/1999/xhtml“>” do?
http://stackoverflow.com/questions/5838343/what-does-html-xmlns-http-www-w3-org-1999-xhtml-do
擷取答案重點如下:
1. Usually a <!DOCTYPE> declaration is used to distinguish between versions of HTMLish lanaguages (in this case, HTML or XHTML).
2. what does <html xmlns="http://www.w3.org/1999/xhtml"> do?
Technically, the xmlns attribute is used by the root element of an XHTML document: (according to Wikipedia)
The root element of an XHTML document must be html, and must contain an xmlns attribute to associate it with the XHTML namespace.
--> it's important to understand that XHTML isn't HTML but XML .The xmlns attribute is just one of those things the document needs to be valid XML.
3. But then why is <html xmlns="http://www.w3.org/1999/xhtml">fixing the CSS?
If structuring your document like so...
<html xmlns="http://www.w3.org/1999/xhtml">
<!DOCTYPE html>
<html>
<head>
[...]
--> ... is fixing your document, the truth is that without <html xmlns="http://www.w3.org/1999/xhtml"> it's behaving normally and with <html xmlns="http://www.w3.org/1999/xhtml"> it's not - and you just think it is, because you're used to writing invalid HTML and thus working in quirks mode.
再者, 就可以介紹DOCTYPE v.s. Quirks Mode了,
這篇文章可以大致看看,
文件型態與接縫模式(DOCTYPE & Quirks Mode):
http://mepopedia.com/?page=866
擷取文章重點如下:
1. 接縫模式/轉折模式 (Quirks Mode)其實就是使用舊的(而往往是錯誤的)CSS/HTML規則的舊瀏覽器模式(主要是IE4、IE5、IE6採用)。
2.而相對於「接縫模式/轉折模式」就是舊式瀏覽器後來改革後尊循標準語法的「標準模式 (Standard Mode)」。而要標示一個網頁是由舊瀏覽器模式或標準模式呈現,就是由 DOCTYPE 的宣告來決定。
3.DOCTYPE 的宣告是為了讓瀏覽器進入「標準模式」。但「標準模式」倒底是什麼呢?簡要而言可以說是完整支援 CSS/HTML 的模式。
4.未宣告文件型態的缺陷基本上就等同於瀏覽器進入 Quirks Mode 時使用 HTML/CSS 語法的限制與缺陷。
What does “<html xmlns=”http://www.w3.org/1999/xhtml“>” do?
http://stackoverflow.com/questions/5838343/what-does-html-xmlns-http-www-w3-org-1999-xhtml-do
擷取答案重點如下:
1. Usually a <!DOCTYPE> declaration is used to distinguish between versions of HTMLish lanaguages (in this case, HTML or XHTML).
2. what does <html xmlns="http://www.w3.org/1999/xhtml"> do?
Technically, the xmlns attribute is used by the root element of an XHTML document: (according to Wikipedia)
The root element of an XHTML document must be html, and must contain an xmlns attribute to associate it with the XHTML namespace.
--> it's important to understand that XHTML isn't HTML but XML .The xmlns attribute is just one of those things the document needs to be valid XML.
3. But then why is <html xmlns="http://www.w3.org/1999/xhtml">fixing the CSS?
If structuring your document like so...
<html xmlns="http://www.w3.org/1999/xhtml">
<!DOCTYPE html>
<html>
<head>
[...]
--> ... is fixing your document, the truth is that without <html xmlns="http://www.w3.org/1999/xhtml"> it's behaving normally and with <html xmlns="http://www.w3.org/1999/xhtml"> it's not - and you just think it is, because you're used to writing invalid HTML and thus working in quirks mode.
再者, 就可以介紹DOCTYPE v.s. Quirks Mode了,
這篇文章可以大致看看,
文件型態與接縫模式(DOCTYPE & Quirks Mode):
http://mepopedia.com/?page=866
擷取文章重點如下:
1. 接縫模式/轉折模式 (Quirks Mode)其實就是使用舊的(而往往是錯誤的)CSS/HTML規則的舊瀏覽器模式(主要是IE4、IE5、IE6採用)。
2.而相對於「接縫模式/轉折模式」就是舊式瀏覽器後來改革後尊循標準語法的「標準模式 (Standard Mode)」。而要標示一個網頁是由舊瀏覽器模式或標準模式呈現,就是由 DOCTYPE 的宣告來決定。
3.DOCTYPE 的宣告是為了讓瀏覽器進入「標準模式」。但「標準模式」倒底是什麼呢?簡要而言可以說是完整支援 CSS/HTML 的模式。
4.未宣告文件型態的缺陷基本上就等同於瀏覽器進入 Quirks Mode 時使用 HTML/CSS 語法的限制與缺陷。
留言
張貼留言