The easiest way would be to create a <div>
that uses your image as a background-image property. Then it would just be a matter of writing the number into that div:
HTML
<div class="square">
123
</div>
CSS
.square {
/* following are width and height of your background image */
width: 100px;
height: 100px;
background: url(yourimg.png) no-repeat 0 0;
}
If you have to use an <img>
tag, it's a little trickier, but still possible:
HTML
<div class="square">
<span>123</span>
<img src="yourimg.png" />
</div>
CSS
.square {
/* following are width and height of your background image */
width: 100px;
height: 100px;
position: relative;
}
.square img {
position: relative;
z-index: 1;
}
.square span {
position: absolute;
z-index: 2;
/* Use to position your number */
top: 10px;
left: 10px;
}
The above works by creating a stack of elements, with the <img>
on the bottom (on account of lower z-index) and the number positioned absolutely above it. This works because the number's parent (<div class="square">
) has position relative so it becomes the coordinate system.