A weird thing when I use PHP Smarty.
It seems the encoding of php file affects the css.
PHP file (ANSI)–test2.php
<?php
include_once("inc/smarty_inc.php");
$smarty->display('test.tpl.htm');
Smarty file(ANSI)–test.tpl.htm
<!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">
<head>
<title>JPR</title>
</head>
<body>
<div style="width:500px;height:200px; background-color:Red;margin:auto;">
test
</div>
</body>
</html>
when these two files are ANSI. The div shows at the center of the page.(both IE and firefox)
when one of them is converted into utf-8. The div shows at the left of the page.(only in IE ,It’s OK with Firefox)
What’s the matter with it? How to make it OK in IE with uff-8?
You are saving the file in UTF-8 with BOM, this causes the first bytes in the response to be the bytes for byte order mark, and not doctype. When IE doesn’t see doctype first, it goes to quirks mode, where the box model is different.
You need to convert it into UTF-8 without BOM. This depends on the text editor or converter you are using.