Doctype meta和quirksmode [英] Doctype meta and quirksmode

查看:87
本文介绍了Doctype meta和quirksmode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果未指定doctype,则会调用Quirksmode。



但是

当从localhost提供服务时,无论文档类型如何,IE看起来都会进入quirksmode。请确认这一点,并且有人可以解释为什么会出现这种情况。

但是

当从localhost IE浏览器进入quirksmode而不管文档类型如何,这可以通过在头部的第一行中包含meta标签来覆盖

 < meta http-equiv =X-UA-Compatiblecontent =IE = edge> 

这对我不起作用...我的语法错了吗?



只有从本地主机提供服务时,头部元才会应用。这是真的,如果是这样的话为什么。



目前在FF Chrome Opera等中无论是从本地主机还是通过网络都可以看到一切正常。



但我只是在IE中出现怪癖模式



我的文档类型是

 <!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>

最后是charset和quirksmode之间的关系吗?

我一直在使用

 < meta http-equiv =content-typecontent =text / html ; charset = utf-8/> 

将apache配置为默认为UTF-8


<我想总结一下这个问题的发现。



在IE9中关闭兼容模式


  1. 在IE 9中右击工具图标并从命令栏选择命令栏 >
  2. 选择兼容性视图设置

  3. 取消选中以兼容模式显示Intranet站点

  4. 选择工具确保兼容性查看未选中
  5. 重新启动浏览器

更改代码的要点


  • html 5 doctype简化了设置doctype的整个问题。

  • 之间似乎有一个关系charset和quirksmode是元的错误,添加了与doctype冲突的charset。




$ b


  1. 忽略localhost quirksmode - 这只在测试时才有意义。

  2. 使用<!Doctype html> 确保html文档从此开始。 N:B这并不意味着这必须是HTML的第一行。 < head> 使用 < meta charset =UTF-8>


  3. 在php初始化时使用<?php header content-Type:text / html; charset = utf-8); ?>


Please can I clarify some thinking here:

Quirksmode is invoked if no doctype is specified.

but

When served from localhost IE appears to go into quirksmode regardless of doctype. Please can this be confirmed and can someone explain why this is the case.

however

When served from localhost and IE goes into quirksmode regardless of doctype this can be overridden by including a meta tag in the first line of the head

<meta http-equiv="X-UA-Compatible" content="IE=edge">

This doesn't work for me ... have I got the syntax wrong?

The meta in the head will only ever be applied when served from localhost? Is this true if so why.

At the moment everything looks fine in FF Chrome Opera etc whether served from localhost or across the net.

But I just get quirks mode in IE

My doctype is

<!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">

Finally is there a relationship between charset and quirksmode?

I have been using

<meta http-equiv="content-type" content="text/html; charset=utf-8" />       

On apache with apache config set to default to UTF-8

解决方案

I wanted to summarise the findings from this question.

To switch off compatibility mode in IE9

  1. in IE 9 right click tools icon and select command bar
  2. from command bar select tools
  3. from tools select Compatibility View Settings
  4. uncheck display intranet site in compatibility mode
  5. from command bar select tools ensure compatibility view is unchecked
  6. Restart Browser

Main points for changing code

  • The html 5 doctype simplifies the whole issue of setting a doctype.
  • The reason that there appeared to be a relationship between charset and quirksmode was the error in the meta to add that charset which put it in conflict with the doctype.

So actions completed to resolve problem.

  1. Ignore localhost quirksmode - this is only significant when testing.
  2. Use <!Doctype html> ensuring that the html document commences with this. N:B this does not mean that this has to be the first line of the HTML. php includes can precede it.

  3. In the <head> Use <meta charset="UTF-8">

  4. In php initialize use <?php header("content-Type: text/html; charset=utf-8"); ?>

这篇关于Doctype meta和quirksmode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆