Skip to content

Poor choice of canvas id #42155

@groda

Description

@groda

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Path2D/Path2D

What specific section or headline is this issue about?

https://developer.mozilla.org/en-US/docs/Web/API/Path2D/Path2D#examples

What information was incorrect, unhelpful, or incomplete?

Using the id "canvas" (as in <canvas id="canvas"></canvas>) might cause some people to create something like
<div id="canvas"> and then getting the error getContext is not a function when running

const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");

I guess I was not the only one running into this error since this answer on StackOverflow getContext is not a function also got 103 upvotes

What did you expect to see?

<canvas id="myCanvas">

or

<canvas id="canvasArea"> (so that it's different from w3schools)

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Content:WebAPIWeb API docsaccepting PRFeel free to open a PR to resolve this issuegood first issueA good issue for newcomers to get started with.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions