0

I am writing a JavaScript implementation of Conway's game of life. It seems like using the to draw my grid is a cool new way to proceed rather than making a HTML table and keeping track of cell ids, but if I write <canvas> in XHTML 1.1 which I usually write, will the code work? Or should I go for table method to draw my base grid for the game?

KrnK
  • 111
  • 4
  • 15
  • The canvas is an HTML5 features. As such, it cannot be expected to work in (X)HTML 1.1 documents. Some browsers _might_ render it correctly, but the standards do not require that they do so. – George Cummins Jun 25 '13 at 17:56
  • What is HTML 1.1? Are you referring to the initial HTML spec from 1993? – imjared Jun 25 '13 at 17:56
  • 1
    I guess he refers to XHTML 1.1 and I don't see how could anybody be 'comfortable' with it – David Fregoli Jun 25 '13 at 17:56
  • 3
    Use HTML5. It’s mostly compatible with XHTML 1.1. You can use void tags with the trailing `/>` if that’s your style. No need to worry about comfort in terms of HTML, really. – Ry- Jun 25 '13 at 17:58
  • If you need to support IE<9 consider using Raphael.js – David Fregoli Jun 25 '13 at 18:00

2 Answers2

2

The canvas element is not part of XHTML 1.1, so the question as such is meaningless. But if you meant to ask whether you can use canvas together with an XHTML 1.1 doctype, then the answer is yes. Browsers don’t care about the doctype, except for determining browser mode (“standards” vs. “almost standards” vs. “quirks”), and this affects many things, but not the recognition and implementation of canvas markup.

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
1

If the canvas-tag works depends on the browser that is used to view it. I believe it can be used in any major browser for some time now. See http://caniuse.com/#search=canvas and this question.

Community
  • 1
  • 1
Sumurai8
  • 20,333
  • 11
  • 66
  • 100
  • I meant XHTML 1.1 and rephrasing my question, I wanted to know if writing in XHTML 1.1 syntax will cause any problems as is HTML5 tag ? Thanks minitech ! One or two more suggestions are welcome though. – KrnK Jun 25 '13 at 18:28
  • I guess the behaviour of browsers is undefined if you are using tags that aren't defined in the markup standards. I personally had no problem when defining a simple `` field in my own xhtml document (the browser did validate and restrict the contents), but I am not sure what it does with the canvas tag. (Yay! I have found a reason to do some more reading on the web :-) ) – Sumurai8 Jun 25 '13 at 18:42
  • @Newcoder [This question](http://stackoverflow.com/questions/256953/html-5-versus-xhtml-1-0-transitional) and related questions might help you in your search. The third answer on that thread says "4.As it has been stated, the DTD serves exactly one purpose IN BROWSERS, and that is to distinguish between standards compliance mode and quirks mode.". I think that might be right, although I have no sources to proof it. – Sumurai8 Jun 25 '13 at 18:53