How do I make one pixel change its color in HTML?

<div style="position: absolute; left: {X}px; top: {Y}px; width: 1px; height: 1px; background-color: red;"></div>

Replace {X} and {Y} with the real coordinates you have. Might need to mess with z-index, depending on the page. Using position: fixed will let you position it relative to the browser, rather than the document.


What you likely need is the canvas element.

Otherwise, the 1 pixel div solution offered by cobbal is a way to do it.

I suspect though, that you're hoping to extrapolate this idea into generally being able to draw arbitrary pixels. In that case, div elements will be extremely slow.

The canvas element is part of the emerging HTML 5 standard. You're not going to have much support with IE browsers, but everything else works these days.


you could put a 1 pixel div with absolute positioning there.

Tags:

Html

Colors

Pixel