In html5 can I set up a canvas background color with javascript or the only way to do it is through css?
css is effectively part of HTML, having been simultaneously released with HTML4. JavaScript, in contrast, is separate from HTML, being a standard developed by Netscape. So within HTML5, there is no such thing as JavaScript. JavaScript can be used with an HTML5 document, but it is not part of HTML5.
maybe I wasn't clear about the problem, I'm using html5 canvas feature using JavaScript to add text, shapes,.. I have seen how you can change the background of the html5 canvas with css and within html, but all the transformation or writing text in the canvas are made using JS, so I'm wondering if it's possible to change the background colour through JS
JS can be used to change css. And since the css can be used to do this.... Couple of references: http://answers.oreilly.com/topic/1819-how-to-change-an-elements-css-properties-with-javascript/ http://www.kirupa.com/html5/changing_css_using_javascript.htm I am sure you can find more.
Join our real-time social learning platform and learn together with your friends!