Am able to set the background-color attribute for HTML body in an inline <style>
command but not when the identical command is moved to an external stylesheet. A specific example is given below.
可以在内联
In test1.html, background-color is set to "blue: in the HTML. File test2.html is identical to test1.html except the <style>
command is commented out. File style.css contains a spec for background-color and also for the <H1>
element (to test that the browser really is reading the stylesheet).
test1。html,背景颜色设置为“蓝色:在html中”。test2的文件。html与test1相同。除了
First test produces orange text against a blue background. Second test produces orange text, but against a white background. I've tried this on Firefox 21, Chrome 19, and IE 9; all give the same results.
第一个测试在蓝色背景下生成橙色文本。第二个测试产生橙色文本,但在白色背景下。我在火狐21、Chrome 19和IE 9上都试过了;结果都是一样的。
What's going on? Any help would be appreciated.
这是怎么呢如有任何帮助,我们将不胜感激。
Here are the three sample files:
以下是三个示例文件:
test1.html:
test1.html:
<HTML>
<head> <link type="text/css" rel="stylesheet" href="style.css">
<style type="text/css">
body {background-color: blue}
</style>
</head>
<body> <h1>This is a test.</h1> </body> </html>
test2.html:
test2.html:
<HTML>
<head> <link type="text/css" rel="stylesheet" href="style.css">
<!-- <style type="text/css">
body {background-color: blue}
</style> -->
</head>
<body> <h1>This is a test.</h1> </body> </html>
style.css:
style.css:
<style type="text/css">
body {background-color: green;}
h1 {color: orange; }
</style>
Thank you!
谢谢你!
1 个解决方案
#1
13
don't use <style type="text/css"></style>
in style.css
不要在style.css中使用
#1
13
don't use <style type="text/css"></style>
in style.css
不要在style.css中使用