【问题标题】:How to skip obsolete attribute error on w3validation?如何跳过 w3validation 上的过时属性错误?
【发布时间】:2016-10-01 14:43:05
【问题描述】:

我有一个 HTML 页面示例,其中包含一些在 HTML5 中已弃用/过时的标签和属性。像 valign、Frameborder、cellspacing 等,但我的网站在我检查时显示 W3validation 错误。我无法删除该标签,所以我在窗口加载后从表中删除 cellspacing 属性。但它显示在 w3 错误中。请帮忙

我的 HTML 代码的示例链接 http://suffitechh.com/pra/w3/index.php

W3validator 链接 https://validator.w3.org/nu/?doc=http%3A%2F%2Fsuffitechh.com%2Fpra%2Fw3%2F

【问题讨论】:

  • 使用 CSS 代替属性
  • 如果我不能使用 CSS 怎么办。实际上在我的情况下,我无法从来自第三方的标签中删除该属性,我无法处理。

标签: javascript html w3c-validation


【解决方案1】:

为什么不摆脱所有这些并使用响应式 iframe?

<style>.embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class='embed-container'><iframe src='http://www.youtube.com/embed/aP3TBpWWwJ8' frameborder='0' allowfullscreen></iframe></div>

您可以使用 iframe 代码之前的百分比来更改大小。

代码笔Demo

此方法从您测试的地方检查清楚..

<!DOCTYPE html>
<html>
<head>
  <style>.embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 60%; height:60%; }</style>
  <title>Test</title>
</head>
  <body>
    <div class='embed-container'><iframe src='http://www.youtube.com/embed/aP3TBpWWwJ8'></iframe></div>
  </body>
</html>

【讨论】:

  • 嘿,约翰尼,但就我而言,我不能使用 CSS。即使我无法删除该属性。因为它们来自第三方模块。
  • 那么为什么不取消模块并使用直接代码呢?在大多数情况下,您应该能够更改或创建 CSS 覆盖。
猜你喜欢
  • 2011-03-03
  • 2020-01-05
  • 1970-01-01
  • 1970-01-01
  • 2018-10-05
  • 1970-01-01
  • 1970-01-01
  • 2021-01-18
  • 1970-01-01
相关资源
最近更新 更多