<!DOCTYPE html>
...
<style scoped>
/* css */
</style>
Các validator w3.org được đem lại cho tôi lỗi này:kiểu phần tử không được phép là con của cơ thể yếu tố trong bối cảnh này (<style scoped> không xác nhận)
Line 883, Column 17: Element style not allowed as child of element body in this context.
(Suppressing further errors from this subtree.)
<style scoped>...
Contexts in which element style may be used:
If the scoped attribute is absent: where metadata content is expected.
If the scoped attribute is absent: in a noscript element that is a child of a head element.
If the scoped attribute is present: where flow content is expected, but before any other flow content other than inter-element whitespace and style elements, and not as the child of an element whose content model is transparent.
Content model for element body:
Flow content.
Đó là sự hiểu biết của tôi rằng Thuộc tính 'scoped' làm cho nó phù hợp với thẻ kiểu nằm ngoài phần đầu của tài liệu. Vậy tại sao người xác nhận không hài lòng với nó?
(Tôi đang sử dụng Wordpress và mã này được sản xuất bởi một plugin, đó là lý do tôi không thể chỉ cần đặt nó trong đầu.)
EDIT: này không xác nhận -
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>title</title>
</head>
<body>
<script type="text/javascript"></script>
<style scoped></style>
</body>
</html>
Nhưng điều đó xảy ra nếu thẻ tập lệnh đi sau thẻ kiểu. lý do cho điều đó là gì?
Hey! Xác nhận W3C hoạt động với điều này nhưng các kiểu trong div không hoạt động nữa: ( – user2718671