Header("Content-Type: Text/Css"); Is Working in Firefox and Chrome, But in Internet Explorer 9 It Shows Up as 'Text/Html'

php Content-type: text/css not working

Try to change the order of your first lines like this :

session_start();
include_once("mysqli.php");
header("Content-type: text/css");

The Content-type can be overrided by the script you are including (mysqli.php).
Also, a "session_start" should be ALWAYS the first thing you do in a php script that uses sessions. (The reason why I put session_start() in first position)

What is X-Content-Type-Options=nosniff?

It prevents the browser from doing MIME-type sniffing. Most browsers are now respecting this header, including Chrome/Chromium, Edge, IE >= 8.0, Firefox >= 50 and Opera >= 13. See :

https://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx?Redirected=true

Sending the new X-Content-Type-Options response header with the value
nosniff will prevent Internet Explorer from MIME-sniffing a response
away from the declared content-type.

EDIT:

Oh and, that's an HTTP header, not a HTML meta tag option.

See also : http://msdn.microsoft.com/en-us/library/ie/gg622941(v=vs.85).aspx

Working in Chrome, but not working in I.E. and Firefox. CSS/STYLE/HTML/PHP

Wrap the header, content and footer in a <div> of constant width to force the next line at some point.

<body>
<div id="wrapper">
<div id="header">header</div>
<div id="content">
<script type="text/javascript">
for (i=0;i<5;i++) { // example in javascript
document.write("<div style='float:left;width:80px;height:80px;background-color:blue;margin:2px;'></div>");
}
</script>
</div>
<div id="footer">footer</div>
</div>
</body>

CSS:

body {
text-align:center;
}
#wrapper {
background-color:#eee;
width:300px;
margin: 0 auto;
text-align:left;
}
#header {
background-color:red;
}
#content {
}
#footer {
clear:both;
background-color:green;
}

Working code & result: http://jsfiddle.net/fsHd5/3/

Resource interpreted as stylesheet but transferred with MIME type text/html (seems not related with web server)

i'd like to start by understanding the problem

Browsers make HTTP requests to servers. The server then makes an HTTP response.

Both requests and responses consist of a bunch of headers and a (sometimes optional) body with some content in it.

If there is a body, then one of the headers is the Content-Type which describes what the body is (is it an HTML document? An image? The contents of a form submission? etc).

When you ask for your stylesheet, your server is telling the browser that it is an HTML document (Content-Type: text/html) instead of a stylesheet (Content-Type: text/css).

I've already checked my myme.type and text/css is already on css.

Then something else about your server is making that stylesheet come with the wrong content type.

Use the Net tab of your browser's developer tools to examine the request and the response.

Adding css rules with text method to style element does not work in IE

This is working for me in IE7:

$('<style type="text/css">body {margin: 0;}</style>').appendTo($('head'));

Another syntax which might be easier to read:

$('head').append('<style type="text/css">body {margin:0;}</style>');

However, calling either .text(val) or .html(val) to set the contents of the style tag will cause an exception to be thrown because they set the innerHTML DOM property which is read-only.

Here is IE's documentation of the innerHTML property:

The property is read/write for all
objects except the following, for
which it is read-only: COL, COLGROUP,
FRAMESET, HEAD, HTML, STYLE, TABLE,
TBODY, TFOOT, THEAD, TITLE, TR.



Related Topics



Leave a reply



Submit