"元素样式不允许作为元素形式的子元素#34;

时间:2015-02-18 00:49:41

标签: html5 w3c-validation

出于某种原因,我收到的错误是:

  

在此上下文中,元素style不允许作为元素form的子元素。 (抑制此子树中的更多错误。)

     

行:17

这是我的代码:

    <!DOCTYPE HTML>
    <html lang="en-US"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <form method="post" spellcheck="true" action="http://www.ijdky.net">


    <input name="text" class="name" placeholder="Please Enter Name">
    <!-- This Part is Where the user will type their name for the comment section-->

    <br> <!-- Break -->
    <br> <!-- Break -->

    <style type="text/css"> textarea.html-text-box {background-color:white;background-repeat:no-repeat;background-attachment:fixed;border-width:4;border-style:solid;border-color:black;font-family:Georgia;font-size:16pt;color:black;}
input.html-text-box {background-color:ffffff;font-family:Georgia;font-size:12pt;color:000000;}
    </style> <!-- The Comment Box -->
    <textarea name="comments" cols="40" rows="10" class="html-text-box">            </textarea>

    <br> <!-- Break -->
    <br> <!-- Break -->

    <input type="submit" value="Submit Comment" class="html-text-box">

    <br> <!-- Break -->
    <br> <!-- Break -->

    <input type="reset" value="Reset Comment" class="html-text-box">

    </form>
    </body>
    </html

    <!-- begin snippet: js hide: false -->

    <!-- language: lang-html -->

    <!DOCTYPE HTML>
    <html lang="en-US"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <form method="post" spellcheck="true" action="http://www.ijdky.net">


    <input name="text" class="name" placeholder="Please Enter Name">
    <!-- This Part is Where the user will type their name for the comment section-->

    <br> <!-- Break -->
    <br> <!-- Break -->

    <style type="text/css"> textarea.html-text-box {background-color:white;background-repeat:no-repeat;background-attachment:fixed;border-width:4;border-style:solid;border-color:black;font-family:Georgia;font-size:16pt;color:black;}
    input.html-text-box {background-color:ffffff;font-family:Georgia;font-size:12pt;color:000000;}
    </style> <!-- The Comment Box -->
    <textarea name="comments" cols="40" rows="10" class="html-text-box"></textarea>

    <br> <!-- Break -->
    <br> <!-- Break -->

    <input type="submit" value="Submit Comment" class="html-text-box">

    <br> <!-- Break -->
    <br> <!-- Break -->

    <input type="reset" value="Reset Comment" class="html-text-box">

    </form>
    </body>
    </html>

我到处搜寻,找不到任何东西。

2 个答案:

答案 0 :(得分:1)

移动它:

<style type="text/css"> textarea.html-text-box {background-color:white;background-repeat:no-repeat;background-attachment:fixed;border-width:4;border-style:solid;border-color:black;font-family:Georgia;font-size:16pt;color:black;} input.html-text-box {background-color:ffffff;font-family:Georgia;font-size:12pt;color:000000;} </style>

<head>元素。

答案 1 :(得分:0)

你做错了是将<style>标记放在错误的位置。将所有<style>声明放在文档的<head>部分中。根据{{​​3}},这就是它必须去的地方。