Html 如何解决此警告类型属性 (cellpadding) 已过时。不鼓励在 HTML5 文档中使用它
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14372380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to solve this warning Type Attribute (cellpadding) is obsolete. Its use is discouraged in HTML5 documents
提问by AbnSrn
I am developing web application using tapestry. I am testing my application using junit test suite and generating war file and html reports, using ant build. In my html report files, I have the following warnings.
我正在使用挂毯开发 Web 应用程序。我正在使用 junit 测试套件测试我的应用程序,并使用 ant build 生成 war 文件和 html 报告。在我的 html 报告文件中,我有以下警告。
Multiple annotations found at this line:
- Attribute (width) is obsolete. Its use is discouraged in HTML5 documents.
- Attribute (cellpadding) is obsolete. Its use is discouraged in HTML5
documents.
- Undefined attribute value (0).
- Attribute (language) is obsolete. Its use is discouraged in HTML5 documents.
Following is my test and report generating code.
以下是我的测试和报告生成代码。
<target name="test" depends="compile" description="Running Test Suite">
<mkdir dir="${target.data.dir}"/>
<mkdir dir="${target.htmlreports.dir}"/>
<junit fork="no" haltonfailure="no" showoutput="yes" printsummary="true" >
<test name="${junit.class.name}" todir="${target.data.dir}"/>
<formatter type="brief" usefile="false"/>
<classpath refid="classpath.test"/>
<sysproperty key="ant.home" value="${ant.home}"/>
<formatter type="xml"/>
</junit>
<junitreport todir="${target.htmlreports.dir}">
<fileset dir="${target.data.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${target.htmlreports.dir}"/>
</junitreport>
</target>
This is my one of the html report file.
这是我的 html 报告文件之一。
<html xmlns:lxslt="http://xml.apache.org/xslt" xmlns:stringutils="xalan://org.apache.tools.ant.util.StringUtils">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Unit Test Results: Summary</title>
<link rel="stylesheet" type="text/css" title="Style" href="stylesheet.css">
</head>
<body onload="open('allclasses-frame.html','classListFrame')">
<h1>Unit Test Results.</h1>
<table width="100%">
<tr>
<td align="left"></td><td align="right">Designed for use with <a href="http://www.junit.org/">JUnit</a> and <a href="http://ant.apache.org/">Ant</a>.</td>
</tr>
</table>
<hr size="1">
<h2>Summary</h2>
<table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<tr valign="top">
<th>Tests</th><th>Failures</th><th>Errors</th><th>Success rate</th><th>Time</th>
</tr>
<tr valign="top" class="Pass">
<td><a title="Display all tests" href="all-tests.html">1</a></td><td><a title="Display all failures" href="alltests-fails.html">0</a></td><td><a title="Display all errors" href="alltests-errors.html">0</a></td><td>100.00%</td><td>0.070</td>
</tr>
</table>
<table border="0" width="95%">
<tr>
<td style="text-align: justify;">
Note: <em>failures</em> are anticipated and checked for with assertions while <em>errors</em> are unanticipated.
</td>
</tr>
</table>
<h2>Packages</h2>
<table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
<tr valign="top">
<th width="80%">Name</th><th>Tests</th><th>Errors</th><th>Failures</th><th nowrap>Time(s)</th><th nowrap>Time Stamp</th><th>Host</th>
</tr>
<tr valign="top" class="Pass">
<td><a href="./test/web/app/sampleApp/juint/package-summary.html">test.web.app.sampleApp.juint</a></td><td>1</td><td>0</td><td>0</td><td>0.070</td><td>2013-01-17T04:52:59</td><td>123456</td>
</tr>
</table>
</body>
</html>
Please any one say how can I remove this warnings.
请任何人说我如何删除此警告。
采纳答案by Tawus
The problem is with the html report not tapestry code. The html report generated uses html 4 attributes which are obsolete now like cellpadding, cellspacing etc. These are just junit test reports. I won't be bothered by their html warnings.
问题在于 html 报告而不是挂毯代码。生成的 html 报告使用 html 4 属性,这些属性现在已过时,例如 cellpadding、cellspacing 等。这些只是 junit 测试报告。我不会被他们的 html 警告所困扰。
回答by Kanhu Bhol
I face the same issue and i got the solution by using HTML 4.01 doc type instead HTML 5 doctype. these warning is only because of HTML5 validator
我遇到了同样的问题,我通过使用 HTML 4.01 文档类型而不是 HTML 5 文档类型得到了解决方案。这些警告只是因为 HTML5 验证器
回答by Sandesh
you can change your code like this to remove warnings like that :
您可以像这样更改代码以删除这样的警告:
<table style="width: 100%;"></table>
回答by Jukka K. Korpela
These warnings come from an HTML5 validator, and apparantly the tool you are using runs such a validator in the background and reports someof the errorsreported, showing them as warnings. By using http://validator.nudirectly on the HTML document, there are many other error messages, too.
这些警告来自一个HTML5验证,并apparantly工具使用的是在后台运行这样的验证,并报告一些的的错误报告,其显示为警告。通过直接在 HTML 文档上使用http://validator.nu,还有许多其他错误消息。
The warning “Undefined attribute value (0).” is enigmatic, however. It's probably an odd way of saying what HTML5 validators say this way, about <table border="0">
: “Error: The value of the border
attribute on the table
element must be either 1 or the empty string. To regulate the thickness of table borders, Use CSS instead.”
警告“未定义的属性值 (0)”。然而,是神秘的。用这种方式表达 HTML5 验证器可能是一种奇怪的方式,关于<table border="0">
:“错误:元素border
上的属性值table
必须是 1 或空字符串。要调节表格边框的粗细,请改用 CSS。”
Check out whether the tools you are using have options for controlling the document type (doctype) used in generated HTML documents (the issues reported are errors by the HTML5 drafts but not according to e.g. XHTML 1.0), or the kind of HTML code generated, or the reporting of issues (e.g., “No warnings”). But just disabling warnings, if possible, might mask out real problems.
检查您使用的工具是否具有用于控制生成的 HTML 文档中使用的文档类型 (doctype) 的选项(报告的问题是 HTML5 草稿的错误,但不是根据例如 XHTML 1.0),或生成的 HTML 代码的类型,或报告问题(例如,“无警告”)。但如果可能的话,仅仅禁用警告可能会掩盖真正的问题。
回答by Erica Kane
To elaborate on Kanhu's reply, you can change the default HTML doctype in Eclipse here:
为了详细说明看胡的回复,您可以在此处更改 Eclipse 中的默认 HTML 文档类型:
Project -> Properties -> Web Content
回答by laxman kodali
Just include the following code before the <html>
tag:
只需在<html>
标签前包含以下代码:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
回答by Brajesh
You can use
您可以使用
<table data-width="100%" class="config-header-font">
instead of
代替
<table width="100%" class="config-header-font">
It works for me.
这个对我有用。
Note: It will remove the warning but may be(not sure) alter your attribute alignment position.
注意:它会删除警告,但可能(不确定)会更改您的属性对齐位置。
回答by Vikram
Add style text-align:center;to your html element
添加样式text-align:center; 到您的 html 元素
回答by Mikeytrova09
The cellpadding attribute of is not supported in HTML5. Use CSS instead.
HTML5 不支持的 cellpadding 属性。改用 CSS。