How to Move an Image in HTML
You do not know how to move an image in HTML. If you do not know how to do it, this article is for you. Most people know how to insert an image, but don’t know how to move an image. Let me tell you:
To move an image or element automatically, you must put your <img> tag within <marquee> tag. The <marquee> tag is used to move an HTML element. Default it moves right to left, we can define our own position using the “direction” attribute. If you can set the direction attribute to “right”, it moves left to right.
Ex:
<marquee direction="right"><img height="200px" src="wonder.png"> </marquee>
Live preview:
See the Pen
Image moving by Wonderdevelop (@wonderdevelop)
on CodePen.
- In the above example code, we have created a <marquee> tag and inside it <img>.
- Then set the “direction” attribute of the marquee tag to “right”, it will move the image left to right.
- And then we add the image using the “src” attribute of img tag.
- See the above live preview output, the image is moving from left to right side continuously and automatically.
I hope you have understood a little about how to move an HTML image in this article. If you have any doubts about this then please comment below.