Hello, let's say I have some given coordinates x and y for a pixel, how could I make it red (keeping everything else on the page just white) in HTML? Is it possible in HTML?
Probably not. It might be possible in Javascript, but I can't imagine it's a well known thing.
Why do you need to change one pixel?
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.
<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.
You can use a pure HTML table (with borderwidth, cellpadding and cellspacing all 0, and tr and td heights all 1) to create something like this:
You can hand-edit the HTML code for this pixel-by-pixel (since it's just one big table).
Note: this is obviously not a practical approach (as you will see as your browser struggles to render a 6 MB HTML file), but it is technically possible to do pixel-by-pixel graphics with pure HTML.