Hello
I am not sure what you asked exactly.
If you asked: Can I put "padding" to the img-tag directly - No.
If you meant: Can I put padding to the div-tag, so that the image will not glue at the left side of the div, but has some space between the "border" of the div and the image - Yes.
1) All the content of div1 "should have the padding":
You can write the padding-property into the class of the div:
css:
.div1{
background-color:cyan;
padding:5px;
}
hmtl:
<div class="div1">
<span class="sp1">some text</span>
<img class="img1" src="./DSCF1556.png">
<a class="a1" href="test.aspx">aaaa</a>
</img>
</div>
If you use the above, the image and text will be 5px away from the left side and top of the div.
2) Only the image "should have the padding", included to new line:
If you just want to have the image to have this space, you can put a div around the image-tag. As it is a div a the image will be shown in a new line.
css:
.padd{
background-color:cyan;
padding:5px;
}
html:
<div class="div1">
<span class="sp1">some text</span>
<div class="padd">
<img class="img1" src="./DSCF1556.png">
<a class="a1" href="test.aspx">aaaa</a>
</img>
</div>
</div>
In that example only the image is displayed 5px from left and top.
3) Only the image "should have the padding", no new line:
If you want to have the image on the same line then the text, then put a around the image-tag and add a class to the span-tag.
Hope this helps.
Meru