-1
    <!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>assignment 4</title>
        <h1>Assignment4- CSS basics</h1>

 <style>
.special
{
text-align:justify;
text-indent:10px;
}

它告诉我元素样式是不允许的,请帮忙

4

3 回答 3

4

<h1>(与其他内容元素一样)不能出现在<head>标签中。
因此,解析器假定您关闭<head>并启动了<body>.

<style>标签只能出现在<head>标签中。
由于解析器之前隐式启动了<body>,因此您会收到错误消息。

于 2013-10-14T16:06:52.557 回答
4

h1不属于该部分head。相反,它应该在body.

它应该看起来像:

<!DOCTYPE html>
<html>
   <head>
      <meta charset="UTF-8" />
      <title>assignment 4</title>
      <style>
         .special {
             text-align:justify;
             text-indent:10px;
         }
      </style>
   </head>
   <body>
      <h1>Assignment4- CSS basics</h1>
   </body>
</html>
于 2013-10-14T16:06:42.247 回答
0

You need to close the head section before including any HTML content. The css should appear within the head section but the H1 tag within the body. ie.

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>assignment 4</title>
<style>
.special
{
   text-align:justify;
   text-indent:10px;
}
</style>
</head>
<body>
    <h1>Assignment4- CSS basics</h1>
</body>
</html>
于 2013-10-14T16:10:06.637 回答