日期:2014-05-16  浏览次数:20468 次

为什么样式表的结果与教材上的不一致
本人是菜鸟,刚学习JS。教材里的这段代码,我拷贝出来,放在IE里测试,但是得到的结果和书上的不一样。是不是教材里有错误呀,或者我做错了,还请各位高手指教,谢谢了。

<html>
<head>
<script type="text/javascript">
<style type="text/css">
<!—-
h1{
color: green;
font-style: italic;
font-size: 12pt;
}
h1.special{
font-size: 24pt;
}
.newheader{
color: yellow;
}
#caps{
font-variant: small-caps;
}
// -->
</style>
</script>
</head>
<body>
<h1>Green, italic, and a point size of 12</h1>
<h1 class="newheader">Yellow, italic, and a point size of 12</h1>
<h1 class="special">Point size of 24</h1>
<p>
Here is some <span id="caps">capitalized</span> text.
</p>
</body>
</html>

------解决方案--------------------
HTML code
<script type="text/javascript">
<style type="text/css">
<!—-
h1{
color: green;
font-style: italic;
font-size: 12pt;
}
h1.special{
font-size: 24pt;
}
.newheader{
color: yellow;
}
#caps{
font-variant: small-caps;
}
// -->
</style>
</script>

------解决方案--------------------
HTML code
<html>
<head>

<style type="text/css">
<!—-
h1{
color: green;
font-style: italic;
font-size: 12pt;
}
h1.special{
font-size: 24pt;
}
.newheader{
color: yellow;
}
#caps{
font-variant: small-caps;
}
// -->
</style>

</head>
<body>
<h1>Green, italic, and a point size of 12</h1>
<h1 class="newheader">Yellow, italic, and a point size of 12</h1>
<h1 class="special">Point size of 24</h1>
<p>
Here is some <span id="caps">capitalized</span> text.
</p>
</body>
</html>

------解决方案--------------------
你把css放到了script标记里面了
------解决方案--------------------
探讨

引用:
HTML code

<html>
<head>

<style type="text/css">
<!—-
h1{
color: green;
font-style: italic;
font-size: 12pt;
}
h1.special{
font-size: 24pt;
}
.newheader{
color: yellow;……