Home > Back-end >  How can I put an image anywhere specified in HTML?
How can I put an image anywhere specified in HTML?

Time:12-11

I'm wondering how I can put an image anywhere I want eg. 20px or the left and 40px of the top.

I've actually done this befor<IMG SRC="something.com"> and then in style: <style> top 30px left 50px</style> BUT it doesn't keep the background of it. Like if I set the background to #000012 then it would make the image go there, just that background is default white.

CodePudding user response:

You can use margin in css like this to position your image 20px to the left and 40px from the top.

img {
    margin-left: 20px;
    margin-top: 40px;
}

CodePudding user response:

You should use position: absolute; or position: relative;.

CodePudding user response:

position: absolute;
left: (your x coordinates here);
top: (your y coordinates here);

absolute position will ignore the default flow of the html page.

  • Related