Solved, html5 validation question...

Posted on 2014-08-25
Last Modified: 2014-08-26
The following line is from Default.aspx:
     <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="StatTypeID" DataSourceID="SqlDataSource1">

The following line is the matching html from visual studio 2010 (with validation set to html5):
     <table id="GridView1" cellspacing="0" rules="all" border="1" style="border-collapse:collapse;">

Question: How can I handle the following errors:
Error: The cellspacing attribute on the table element is obsolete. Use CSS instead.
…ng="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">

Error: The rules attribute on the table element is obsolete. Use CSS instead.
…ng="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">

Warning: The border attribute on the table element is presentational markup. Consider using CSS instead. For example: table, td, th { border: 1px solid gray }
…ng="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">

Open in new window

When I use:
    border:1px solid green;
rules:all;       /*  <-- not recognized */

Open in new window

some attributes are handled but It is not clear what I should write for cellspacing="0" for css to recognize it.

Thank you.
Question by:Mike Eghtebas
    LVL 53

    Assisted Solution

    table {
        border-spacing: 0;
        border-collapse: collapse;

    Should do it for you.

    LVL 33

    Author Comment

    by:Mike Eghtebas
    Hi Cd&,

    Thank you for the solution. I am still getting the errors because the rendered page is including inline styling which overwrites any external CSS.

    How can I make the grid view not to include these inline attributes?

    FYI, I have used gridview from the toolbar; perhaps I need not to use gridview from the tollbar. Instead, I may have to populate this gridview from codebehinde to have a better control on its styling.

    If this seems a workable solution, please give me some lines of code to get it started in this direction.

    Thanks again,


    Here is .aspx file incase you like to see it:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
    <!DOCTYPE html>
    <head runat="server">
        <meta charset="utf-8" />
        <link href="style/form1through6.css" rel="stylesheet" type="text/css" />
        <form id="form1" runat="server">
            <asp:GridView ID="GridView1"  runat="server" AutoGenerateColumns="False" 
                DataKeyNames="StatTypeID" DataSourceID="SqlDataSource1">
                    <asp:BoundField DataField="Sort" HeaderText="Sort" SortExpression="Sort"/>
                    <asp:BoundField DataField="CurrYearCount" HeaderText="CurrYearCount" 
                    <asp:BoundField DataField="LastYearCount" HeaderText="LastYearCount" 
                    <asp:BoundField DataField="PI" HeaderText="PI" ReadOnly="True" 
                    <asp:BoundField DataField="StatTypeID" HeaderText="StatTypeID" 
                        InsertVisible="False" ReadOnly="True" SortExpression="StatTypeID"/>
                    <asp:BoundField DataField="YYYY" HeaderText="YYYY" SortExpression="YYYY"/>
                    <asp:BoundField DataField="StatType" HeaderText="StatType" 
                    <asp:CheckBoxField DataField="ExcludeYN" HeaderText="ExcludeYN" 
                    <asp:BoundField DataField="Region_ID" HeaderText="Region_ID" 
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ROD_July18ConnectionString %>" 
                SelectCommand="spAuunuaCountMedCtr" SelectCommandType="StoredProcedure">
                    <asp:Parameter DefaultValue="2" Name="StatType_ID" Type="Int32" />
                    <asp:Parameter DefaultValue="2014" Name="YYYY" Type="String" />
                    <asp:Parameter DefaultValue="1" Name="RegionID" Type="Int32" />

    Open in new window

    LVL 53

    Expert Comment

    I show up with an asp certification, but that is based on helping with HTML and CSS problems posted in the asp topic.  I am definitely not and ASP expert. So I don't know what to suggest here.  I never let use anything that generates things I do not explicitly request.

    So about the best I can suggest is to do direct coding to replace anything that is forcing undesireable code in the page.

    Sorry I can be more help; I've sent a message to another Expert who is more ASP oriented to see if they can follow up.

    LVL 52

    Accepted Solution

    I don't use .net either (just the old fashioned classic asp or php).  However, I think you need to set things like cell spacing and padding to -1

    I don't have access to my testing server to try this out but give it a try and see if it will get rid of those items.   Then you can use pure css.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Suggested Solutions

    What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now