yamini r
yamini r

Reputation: 203

How to position the image in html with inline css?

I am trying to position an image somewhere in particular, so I need to use "top", "left" parameters instead of just "align: center". I used the below code, but it fails to move the image anywhere on the screen, it remains constant at a place.

<img src="./assets/button.png" alt="button" position: absolute; width: 346px; height: 40px; left: 1041px; top: 546px;>

Kindly help solve this. Thanks in advance!

Upvotes: 1

Views: 2854

Answers (3)

RicardoReyes
RicardoReyes

Reputation: 21

The problem is that you're missing the "style" attribute, otherwise your code should run properly.

Upvotes: 2

moshfiqrony
moshfiqrony

Reputation: 4723

Use like this

<img src="./assets/button.png" alt="button" style="position: absolute; width: 346px; height: 40px; left: 1041px; top: 546px;">

Also as you are positioning it to a specific position you have to be sure about which it is relative to.

Suppose you want it relative to a div. Make that div's style like this

<div style="position: relative;">
// other codes here
</div>

Upvotes: 2

Ayush Bhatt
Ayush Bhatt

Reputation: 39

Use something like this . Put all the css properties in the style

<img 
    src="./assets/button.png"
    alt="button"
    style="position:absolute; width:346px; height:40px; left:1041px; top:546px;"
>

Upvotes: 2

Related Questions