Learn Create Your Own Split Screen

Next Page

Uniquely identifying an HTML Element is achieved using the ID attribute.

You've been doing this all through S2JS for the canvas element, but in fact it can be applied to any sort of HTML Element.

<canvas id=MyCanvas> </canvas> <button id=MyGameStart> Click to Start </button> <div id=MyScore class="bigstuff"> </div>

It's possible to reference an ID within the <style> section by prefixing the ID with a hash sign
<style> #MyCanvas {background-color:pink}
However, it's usually not a good approach to take. You're much better using class and tag names, so your CSS rules apply to groups of elements. Using IDs means you end up with a forest of CSS entries, and changing your mind about anything becomes very laborious.

Just because you can do it, doesn't mean you should.

But ID will become useful for other reasons.