I have an image icon in an HTML page that should show right to a label only when some condition is true. If the condition is false, it should not show, but it should still take up the same space.
I'm sure most of you have done something like this and I got a couple of solutions.
- Put the
img
tag as usual but add to its style attributevisibility: hidden
when the condition is false. - Specify the
width
andheight
style attribute for theimg
tag and use a transparent 1 X 1 image when the condition is false.
I don't like either since it seems like pre-CSS 3. Does anyone know the best practice of doing this?
EDIT: When the image does not show, I don't need the image, but I need its space not to disrupt the positioning of the rest of the elements.