Skip to content

Conversation

@Mouni-Sanaboyina
Copy link

Description

This PR updates the Canvas API basic example to use a more descriptive canvas element ID, improving clarity and readability for beginners.

Motivation

Using a generic ID like canvas is not a best practice. A descriptive ID makes the example easier to understand and aligns with recommended coding conventions in documentation.

Additional details

N/A

Related issues and pull requests

Fixes #42155

@Mouni-Sanaboyina Mouni-Sanaboyina requested a review from a team as a code owner December 23, 2025 11:59
@Mouni-Sanaboyina Mouni-Sanaboyina requested review from sideshowbarker and removed request for a team December 23, 2025 11:59
@github-actions github-actions bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Dec 23, 2025
<canvas id="canvas"></canvas>
<canvas id="drawingCanvas"></canvas>
```
Use a descriptive ID to make it clear what the canvas element is used for.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
Use a descriptive ID to make it clear what the canvas element is used for.
Use a descriptive ID to make it clear what the canvas element is used for.


The actual drawing is done using the {{domxref("CanvasRenderingContext2D")}} interface. The {{domxref("CanvasRenderingContext2D.fillStyle", "fillStyle")}} property makes the rectangle green. The {{domxref("CanvasRenderingContext2D.fillRect()", "fillRect()")}} method places its top-left corner at (10, 10), and gives it a size of 150 units wide by 100 tall.


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change

@sideshowbarker sideshowbarker removed their request for review December 23, 2025 13:37
@Josh-Cena
Copy link
Member

Duplicate of #42159

@Josh-Cena Josh-Cena marked this as a duplicate of #42159 Jan 8, 2026
@Josh-Cena Josh-Cena closed this Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Poor choice of canvas id

2 participants