【问题标题】:The w3.org validator erorw3.org 验证器错误
【发布时间】:2015-08-30 21:25:55
【问题描述】:

w3.org 验证器给我这个错误:

Line 322, Column 29: Element style is missing required attribute scoped.
<style type="text/css">

样式化我的 html 代码:

     <!DOCTYPE html>
    <head>
    <meta charset="UTF-8">
    <title>title</title>
    </head>
    <body>
    <style type="text/css"></style>
<script type="text/javascript"></script>
    </body>
    </html>

对于 wordpress 中的重力形式插件。

    <style type="text/css">
.gright,.gform_wrapper form ,.gform_wrapper ul li:before, .gform_wrapper ul li:after, .gform_wrapper ul.gform_fields {
text-align: right !important;
direction:rtl !important;
}
.gleft,.gform_wrapper input[type="url"], .gform_wrapper input[type="email"],
.gform_wrapper input[type="tel"], .gform_wrapper input[type="number"], 
.gform_wrapper input[type="password"],body.rtl .gform_wrapper input[type="email"], body.rtl .gform_wrapper input[type="password"],
body.rtl .gform_wrapper input[type="url"], body.rtl .gform_wrapper input[type="tel"],body .gform_wrapper.gf_rtl_wrapper input[type="email"],
body .gform_wrapper.gf_rtl_wrapper input[type="password"], body .gform_wrapper.gf_rtl_wrapper input[type="url"], body .gform_wrapper.gf_rtl_wrapper input[type="tel"] {
text-align:left !important;
direction:ltr !important;
}
.gform_wrapper .ginput_complex .ginput_left {
float: right !important;
}
.gform_wrapper .ginput_complex .ginput_right {
float: left !important;
                        }
                        .gform_wrapper .gfield_checkbox li label,
                        .gform_wrapper .gfield_radio li label {
                            margin-right:20px !important;
                        }↩
                        .gform_wrapper .ginput_complex.ginput_container.has_first_name.has_middle_name.has_last_name span.name_first,
                        .gform_wrapper .ginput_complex.ginput_container.has_first_name.has_middle_name.has_last_name span.name_middle,
                        .gform_wrapper .ginput_complex.ginput_container.has_first_name.no_middle_name.has_last_name span.name_first{
                            margin-right:0px !important;
                            margin-left: 1.3% !important;
                        }
                    </style>

请帮我修复 html 或 wordpress 中的插件。

【问题讨论】:

  • 缺少&lt;/style&gt;&lt;style&gt;应该在&lt;head&gt;
  • stackoverflow.com/questions/27539084 的副本? -> 要么按照 Alex K. 的建议将样式移到头部,要么使用 scoped 属性。
  • 不 - 未修复 - 帮帮我
  • 从 中移除
  • 请注意,&lt;style&gt;&lt;script&gt; 标签的 type 属性在 HTML5 中是无用的,除非您使用 CSS 和 javascript 之外的其他东西...

标签: html w3c-validation


【解决方案1】:

&lt;style&gt; 元素可以将scoped 属性应用于页面的某个部分,并且需要“限定”以将其包含在该部分中。

如果存在,则表示样式仅用于 以样式元素的父元素为根的子树,而不是 整个文档。

通过将样式元素放在正文中,验证器会假定您正在尝试这样做,如果您不这样做,则将其标记为错误。因此,如果您按照其他人的建议进行操作,并将样式正确地放在它所属的 head 元素中,或者按照规范说明正确地确定样式的范围,错误就会消失。但是,我不记得浏览器是否会这样做。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 2014-06-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多