, html5 validation question...

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.
LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Should do it for you.

Mike EghtebasDatabase and Application DeveloperAuthor Commented:
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

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.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.