W3C markup validation issue

W3C markup validation issue

remsyremsy Posts: 10Questions: 0Answers: 0
edited January 2011 in General
Hi. I have this in my html:



the W3C validator complains with a message: end tag for "TABLE" which is not finished, is there a way to get rid of this error with datatables so it'll pass W3C validation ?

the columns are declared in the table script itself like this:

"aoColumns": [
{"sTitle": "ColA", "bSortable": true, "sWidth": "550px"},
{"sTitle": "ColB", "bSortable": false, "sWidth": "120px"},
{"sTitle": "ColC", "bSortable": true, "sWidth": "70px"},
{"sTitle": "ColD", "bSortable": true, "sWidth": "70px"}
],

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Looking that the HTML 4 strict DTD there is:

    [code]
    <!ELEMENT TABLE - -
    (CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>
    [/code]
    So there needs to be a TBODY tag. Adding that in should do it.

    Allan
  • remsyremsy Posts: 10Questions: 0Answers: 0
    Hi Allan, I tried all sort of combinations but it still doesn't pass validation, do you think converting it to XHTML would help? thanks !
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Probably not - from the spec it says that the TBODY needs a TR element and the TR needs a TH|TD - so it looks liek to pass the validator you do actually need a valid table in place. What you could do is simply remove the elements with Javascript before then initialising your table.

    Allan
  • remsyremsy Posts: 10Questions: 0Answers: 0
    Hi Allan, I solved it by assigning the html content corresponding to the DIV container inside the table script:

    $('#tableContainer').html('');

    I took this from this example:

    http://www.datatables.net/examples/data_sources/js_array.html

    This way the markup only shows a div.

    Remsy.
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Heh - good plan :-).

    Allan
This discussion has been closed.