开发者

Cross Browser Compatibility and docType declaration

开发者 https://www.devze.com 2023-04-06 17:05 出处:网络
I designed a webpage and tested it on firefox, chrome & IE-8. The webpage is displayed fine on 开发者_如何学JAVAfirefox & chrome but not on IE.

I designed a webpage and tested it on firefox, chrome & IE-8. The webpage is displayed fine on 开发者_如何学JAVAfirefox & chrome but not on IE. In the process of making it compatible, I changed the DocType declaration from HTML 4.01 Transitional to XHTML 1.1 to HTML 4.01 Strict. This failed to fix the cross compatability. Also, I found that the webpage design is messed up on firefox & chrome when I change the DocType from HTML 4.01 Transitional to XHTML 1.1.

Now my question is, if DocType does matter in designing webpages, which one should I use for cross compatibilty? Is there another solution that does not involve DocType?


It sounds like you're only changing the DOCTYPE, but not changing any HTML or CSS. This is something you'll need to do since each DOCTYPE will be rendered differently.

I recommend one of the STRICT ones - HTML4.01 STRICT, XHTML1.0 STRICT, or XHTML1.1, depending on your needs. Or HTML5 (although I haven't used it yet myself). Also, make sure you've got the doctype declaration correct and have included the xmlns in the html tag if you're using XHTML.

For reference:

  • QuirksMode has a lot a great information, including browser compatibility info.
  • A List Apart also has really helpful articles.
  • I refer to the HTML and CSS2 Specifications often.

And to check your doctypes:

HTML 4.01 Strict, Transitional, Frameset

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

XHTML 1.0 Strict, Transitional, Frameset

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

XHTML 1.1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

HTML5

<!DOCTYPE html>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号