- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set the starting position of a background image in JavaScript DOM?
To set the starting position of a background image in JavaScript, use the backgroundposition property. It allows you to set the position of the image.
Example
You can try to run the following code to learn how to set all the position of a background image with JavaScript −
<!DOCTYPE html> <html> <head> <style> body { background-repeat: no-repeat; } </style> </head> <body> <button onclick="display()">Click to Set background image</button> <script> function display() { document.body.style.backgroundImage = "url('https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg')"; document.body.style.backgroundPosition="top right"; } </script> </body> </html>
- Related Articles
- How to set a background image to be fixed with JavaScript DOM?
- Set the Background Image Position with CSS
- How to set the size of the background image with JavaScript?
- How to set the positioning area of the background image with JavaScript?
- How to set background image of a webpage?
- How to style background image to no repeat with JavaScript DOM?
- How to set all the background properties in one declaration with JavaScript DOM?
- How to set a background image to a JavaFX chart?
- How to set background image in CSS using jQuery?
- FabricJS – How to set the background colour of selection of an Image?
- How to set the position of Image from left using FabricJS?
- How to set the position of Image from top using FabricJS?
- How to set the painting area of the background with JavaScript?
- Set the background image of an element with CSS
- How to return the background color of an element with JavaScript DOM?

Advertisements