How to solve this warning Type Attribute (cellpadding) is obsolete. Its use is discouraged in HTML5 documents
Asked Answered
U

9

6

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.

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 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.

Uptotheminute answered 17/1, 2013 at 4:49 Comment(2)
If that is your code: switch the markup to use CSS instead of the properties. Bonus points for removing tables, if applicable. Otherwise, ignore it and request (to the people responsible) that the reports support HTML5. (Also, consider submitting a patch.)Prohibitive
instead of giving the attribute you can specify it in style attribute like this style="width:95%;"Backsword
G
1

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.

Geodesy answered 17/1, 2013 at 5:40 Comment(0)
S
3

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

Soggy answered 8/8, 2013 at 8:12 Comment(1)
where you changed HTML 4.01 doc type instead HTML 5 doctype?Auriol
K
3

you can change your code like this to remove warnings like that :

<table style="width: 100%;"></table>
Kalong answered 26/6, 2015 at 11:39 Comment(0)
A
2

These warnings come from an HTML5 validator, and apparantly the tool you are using runs such a validator in the background and reports some of the errors reported, showing them as warnings. By using http://validator.nu directly on the HTML document, there are many other error messages, too.

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.”

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.

Airspace answered 17/1, 2013 at 8:59 Comment(0)
G
1

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.

Geodesy answered 17/1, 2013 at 5:40 Comment(0)
F
1

To elaborate on Kanhu's reply, you can change the default HTML doctype in Eclipse here:

Project -> Properties -> Web Content 
Fimbria answered 6/8, 2014 at 0:3 Comment(0)
K
1

Just include the following code before the <html> tag:

<%@ 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">
Kobe answered 3/9, 2014 at 7:30 Comment(1)
If we want to use html 5 then we can't add <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">Varini
P
0

Add style text-align:center; to your html element

Petua answered 14/6, 2017 at 10:35 Comment(0)
A
0

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.

Agueweed answered 19/12, 2017 at 10:2 Comment(0)
G
-2

The cellpadding attribute of is not supported in HTML5. Use CSS instead.

https://www.w3schools.com/tags/att_table_cellpadding.asp

Garceau answered 12/9, 2017 at 14:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.