Phi*_*arc 8 html php character-encoding html-head meta-tags
当浏览我的网站与谷歌浏览器的最新版本,并使用F12寻找到的来源,所有的内容之间<head>,并</head>显示为空.在最新版本的Firefox和IE上,一切都是正确的.
实际上,内容会在Google Chrome上移动到正文中.
这显然不是CSS问题.我正在使用Twitter Bootstrap CSS和JS,以及一个MVC PHP框架.有人有提示吗?
这是我的document.html页面:
<!DOCTYPE html>
<html lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title><?php echo (Template::$titre); ?></title>
<?php foreach(Template::$meta as $key=>$value): ?>
<meta name="<?php echo $key; ?>" content="<?php echo $value; ?>" />
<?php endforeach; ?>
<link rel="shortcut icon" href="<?php echo WEB; ?>assets/style/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="<?php echo WEB; ?>assets/style/bootstrap.min.css" />
<link rel="stylesheet" href="<?php echo WEB; ?>assets/style/bootstrap-responsive.min.css" />
<link rel="stylesheet" href="<?php echo WEB; ?>assets/style/main.css" />
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<?php require Template::child(); ?>
(...)
Run Code Online (Sandbox Code Playgroud)
而Firebug观察到的来源:
<html lang="fr"><head></head><body>?
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Vélos d'occasion dans toute la France</title>
<meta name="keywords" content="velos d'occasion, velos dans toute la France, velos occasion Toute la france, velo occasion, velo">
<meta name="description" content="Petites annonces de velos d'occasion dans toute la France, velo d'occasion à vendre Toute la france">
<link rel="shortcut icon" href="/assets/style/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="/assets/style/bootstrap.min.css">
<link rel="stylesheet" href="/assets/style/bootstrap-responsive.min.css">
<link rel="stylesheet" href="/assets/style/main.css">
<link href="http://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<section id="maincontainer">
<div class="container">
(...)
Run Code Online (Sandbox Code Playgroud)
编辑:问题解决了,Notepad ++在UTF8编码,我改为ANSI并且工作正常.
在文档的开头有一些格式错误的字符.
我通过W3C验证器运行了您的页面,它显示:
错误第1行,第1列:找到非空格字符而未先查看doctype.预期
<!DOCTYPE html>.
这似乎导致Chrome放弃您的doctype并以Quirks模式呈现页面,正如您可以通过有趣的按钮和文本字段高度看到的那样.尝试删除DOCTYPE之前的任何奇怪的东西(或删除DOCTYPE并重新键入)