0

Hi I'm relatively new at web development and I'm trying to get this working for a class. The goal is to use an embedded css class to make font that is both bold and italic. So far I have this:

<!DOCTYPE html><!--Chapter 3 ex 4, a demonstration of class-->
<html lang="en"><!--opens html and sets language to english-->
<head><!--opens head-->
<title>Chapter 3 ex 4</title><!--sets the title of the page-->
<style><!--opens embedded style-->
.new 
{   
font-weight: bold;<!--creates a class new-->
font-style: italic; <!--that is both bold and italic--> 
}
</style> <!--closes embedded style-->
<meta charset="utf-8">
</head> <!--Closes head-->
<body>
<p class="new">Test of new class</p>
</body>
</html>

The problem is that the text is not being affected at all by the "new" class. I have discovered that if I remove the lang="en" from the tag the font text becomes bold. Anyone have any ideas what I can do to fix this?

4

3 回答 3

1

CSS 中的注释是用/* your comment */HTML 样式的注释代替的。您的 CSS 按原样无效。

<!--opens embedded style-->
<style>
.new 
{   
font-weight: bold; /* creates a class new */
font-style: italic; /* that is both bold and italic */ 
}
</style> <!--closes embedded style-->
于 2013-10-09T15:47:29.837 回答
1

您在嵌入式样式表中使用了不正确的注释:

.new 
{       
font-weight: bold;/*creates a class new*/
font-style: italic; /*that is both bold and italic*/
}
于 2013-10-09T15:48:14.293 回答
0

如果您删除标签<!-- html comments -->内的所有内容,它会顺利运行。<style>

刚刚用我的浏览器测试了一下。

于 2013-10-09T15:48:56.307 回答