![](/img/trans.png)
[英]W3C error: document type does not allow element X here; missing one of Y start-tag
[英]W3C HTML5 ERROR Start tag head seen but an element of the same type was already open
已看到开始标记头,但已打开相同类型的元素。 我还遇到了其他一些错误:
“看到 <?。可能的原因:尝试在 HTML 中使用 XML 处理指令。(HTML 中不支持 XML 处理指令。)“
和
“ scope 中没有 p 元素,但看到了一个结束标签。”
我不知道如何解决它们。
<!DOCTYPE html>
<html lang="pl">
<style>
html, body { margin: 0; padding: 0; color: black; background-color: grey;}
#strona { position: absolute; color: white}
#rects { position: relative; width: 300px; height: 125px; border: 1px solid #FF0000; color: yellow; margin: 5px; padding: 2px;}
</style>
<head>
<meta charset="UTF-8"/>
<title> site</title>
</head>
<body>
<div> <script>
function clickbutton1(){
document.getElementById("opis").innerHTML = Date();
}
</script>
</div>
<div id="strona">
<h1>test</h1>
<?php
echo "<p>data replacement</p>";
echo "<div id='rects'>
<!-- starting of the function -->
<p id='opis'> internal description </p>
<script>
document.getElementById('rects').onclick = clickbutton1;
</script>
</div>";
?>
</div>
</body>
</html>```
在div#strona
下添加了一些字符,这些字符干扰了代码的运行方式。
为了使 Javascript 正常工作,将clickbutton1()
onclick function 直接添加到 Z4C4AD5FCA2E7A81CAA4Z4 元素。
以下是在各自文件中使用 HTML/CSS/Javascript 重新格式化的代码:
function clickbutton1() { return document.getElementById("opis").innerHTML = Date(); }
html, body { margin: 0; padding: 0; color: black; background-color: grey; } #strona { position: absolute; color: white } #rects { position: relative; width: 300px; height: 125px; border: 1px solid #FF0000; color: yellow; margin: 5px; padding: 2px; }
<head> <meta charset="UTF-8" /> <title> site</title> </head> <body> <div id="strona"> <h1>test</h1> <div onclick="clickbutton1()" id='rects'> <p id='opis'></p> </div> </div> </body>
@weemizo 是的! 我将 CSS styles 添加到style
标签中,并将 JS 添加到script
元素中。 它们现在都放置在head
标签中。
<html> <head> <meta charset="UTF-8" /> <title>Site</title> <style> html, body { margin: 0; padding: 0; color: black; background-color: grey; } #strona { position: absolute; color: white } #rects { position: relative; width: 300px; height: 125px; border: 1px solid #FF0000; color: yellow; margin: 5px; padding: 2px; } </style> <script> function clickbutton1() { return document.getElementById("opis").innerHTML = Date(); } </script> </head> <body> <div id="strona"> <h1>test</h1> <div onclick="clickbutton1()" id='rects'> <p id='opis'></p> </div> </div> </body> </html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.