简体   繁体   中英

Internet Explorer external css issue

I am working on a site ( www.eticket24.at ) and have to create an external CSS for both the header and footer.

If I view the header, for example, seperately in FireFox by going to www.eticket24.at/header.php , it looks fine — the CSS is all there, and it's styled the way it should be. However, in IE8, if I do the same, the style is gone compeletely. It works on the index page, but not when I view it alone.

I am using link rel="stylesheet" href="http://www.eticket24.at/et24_header.css to include the CSS at the top of my header.php page. Same goes for my footer.php page.

So, what's the problem with Internet Explorer this time? Why won't it behave?

Thanks.

It's because when you're vewing the header on its own, Firefox will correct the incomplete markup and make the page a valid html document with the <html><body>...</body></html> tags.

IE will not do this, so the styles will not be applied as it doesn't know to do this on an invalid page.

This is also why the page looks correct on the live site.

Your link is inside the body of the page... try putting it inside the <head /> section. Also add type="text/css" to the <rel /> tag.

header.php doesn't return a full HTML page, so maybe Internet Explorer is borking on that. Even though Firefox renders it, I don't think you can necessarily expect all browsers to do so.

As ifaour mentioned, you might want to move your <link> tags into the <head> tag, as they're not meant to go in <body> .

我在.php文件中包含了所有的CSS而不是链接它们并更改了一些div名称(从to到to。这有助于因为之前div的css样式被其他公司的css样式覆盖,所以我不得不创建我自己唯一的div名称,而不是标准的HTML5名称

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM