I’m currently trying to write some Javascript to loop through the elements in a table, but was wondering what the best practise was. I could just call .cells[] on my table object to get all of the cells in the table, but the W3Schools page says that this is not a W3C standard – should I avoid it then?
The other option is to use .rows[] to get all the rows (which is W3C Standard), then .cells[] on each of the rows (again, W3C Standard). Basically – how important is it that I stick to W3C Standard methods?
Where the standard exists, it’s generally preferable to use it: there’s more chance that it’s well-supported in all your target browsers and wide adoption of standards helps prevent the proliferation of non-standard proprietary APIs.
This particular case is a no-brainer: the
cellsproperty of a<table>element isn’t supported in Firefox, so you can’t use it on the web.